ATEasy v8.0 supports calling, controlling and communicating with Windows console applications. This allows test engineers leverage existing script code written in languages such as TCL, Perl, PHP and use the script from their tests.
This article describes the simple process involved in calling a TCL and Perl script from ATEasy. The example code involves with using the ATEasy Standard I/O Process Driver StdIoProcess.drv. The example scripts will wait for ATEasy to send data via the standard I/O and then will respond by echoing this data back to ATEasy. Similar techniques can be used to control any Windows command line utilities.
The ATEasy StdIoProcess driver allows a user to call console based executable, pass arguments,monitor the process’s standard output and send data to the process via its standard input.
Note that the following software components are required to get started:
- Installation of an script interpreter
The first example calls a TCL script. This example is using the ActiveTCL interpreter which was installed in the C:\tcl folder. The script will accept two numeric values and output the sum of those two values:
- A script interpreter executable that can take the filename of the script to be run from its first command line argument.
puts "TCL Script Started"
gets stdin x
gets stdin y
set result "The Sum is: "
append result [expr $x+$y]
Here is the ATEasy code using the StdIoProcess driver. ATEasy pass in two numbers 4 and 5 and read back the result as calculated by the RCL script:
StdIoProcess Execute(sTclPath, "\""+sExamplePath+"StdIoProcessAdd.tcl\"", "4\r\n5\r\n", True)
s=StdIOProcess Get StdOutput()
if StdIOProcess Get ExitCode()<>0
if val(right(s, 3))<>9
Similar to the TCL interpreter, the Perl interpreter installed from Strawberry Perl can be used. In the following example we run StdIoProcessAdd.pl, passing two numbers 45 and 9 and getting back the sum as shown here:
! add two numbers using PERL
StdIoProcess Execute(sPerlPath, "\""+sExamplePath+"StdIoProcessAdd.pl\"", , False)
StdIoProcess Read(s, True)
The contents of the perl script TestScript.pl is the following:
print "Perl Script Started";
$x = <STDIN>;
$y = <STDIN>;
The referenced files are included in ATEasy v8.0 and above (see StdIoProcess.prj example). The example also contains example of executing the Windows command prompt (CMD.EXE). Here is the ATEasy form that is provided with the example: