TestComplete is an automated testing tool that allows writing tests in scripting languages such as Python, JScript or VBScript. You can integrate TestLeft tests into TestComplete projects to run them as a whole. This way your QA engineers will take advantage of tests created by developers.
The way you can run TestLeft tests from TestComplete depends on how you created your TestLeft tests:
JUnit and TestNG Tests
If you have used the JUnit or TestNG unit testing framework to create your TestLeft tests, you can run your tests by using TestComplete integration with these frameworks:
-
Compile your TestLeft tests or create a Maven project.
-
In TestComplete, go to Tools > Options > Engines > Unit Testing and specify the path to the Java Virtual machine:
-
Open the TestComplete project where you want to add your TestLeft tests, or create a new project.
-
Add a new Unit Testing collection to the project:
-
Depending on the unit testing framework you have used to create your TestLeft tests, add a new JUnit or TestNG item to the collection:
-
Configure the added item to run your TestLeft tests:
-
To run your tests by using Maven, select Use Maven project. Specify the path to the Maven configuration file (pom.xml):
-
To run your tests using the classpath, select Specify the classpath directly. Enter your test classpaths and the paths to all modules and libraries your tests use, including:
-
The path to your unit testing framework:
For JUnit: The path to the junit-n.nn.jar file.
For TestNG: The path to the testng-n.n.n.jar file.
-
The paths to your test classes.
-
The path to the TestLeft library. By default, it is located at <TestLeft 15>\API\Java\testleft-15.40.jar.
-
The paths to all modules that the TestLeft library uses:
-
The paths to all other classes that your tests use.
The examples below demonstrate how you can specify the classpaths:
For JUnit:
C:\Tests\TestLeftProject\test-classes;C:\TestLeft 15\API\Java\testleft-15.40.jar;C:\gson\*;C:\apache\commons\commons-compress\*;C:\objenesis\*;C:\apache\httpcomponents\*;C:\apache\httpcomponents\httpcore\*;C:\commons-logging\commons-logging\*;C:\commons-codec\commons-codec\*;C:\junit\*;C:\hamcrest\hamcrest-core\*For TestNG:
C:\testng\*;C:\Tests\TestLeftProject\test-classes;C:\TestLeft 15\API\Java\testleft-15.40.jar;C:\gson\*;C:\apache\commons\commons-compress\*;C:\objenesis\*;C:\apache\httpcomponents\*;C:\apache\httpcomponents\httpcore\*;C:\commons-logging\*;C:\commons-codec\* -
-
-
Specify the test classes you want to run:
-
Go to View > Organize Tests and add the configured test to your project’s test items. This way, your TestLeft tests will be run automatically when you run the TestComplete project.
-
Run the TestComplete project.
The TestLeft test results are stored separately from the native JUnit and TestNG test results. Therefore, they will not be included into the TestComplete test log. However, you can configure your TestLeft to store their results to an external file. See Saving Test Logs.
MSTest Tests
To run MSTest-based TestLeft tests from TestComplete, you can use TestComplete’s MSTest integration.
-
Compile your TestLeft tests to a .dll. This is the default output type when using TestLeft’s Visual Studio project templates.
-
In TestComplete, go to Tools | Options | Engines | Unit Testing and specify the path to mstest.exe. A typical path is C:\Program Files\Microsoft Visual Studio <ver>\Common7\IDE\mstest.exe.
-
Open the TestComplete project where you want to add your TestLeft tests, or create a new project.
-
Add a new project item of the Selenium or Unit Testing type.
-
And a child item of the MSTest type.
-
Double-click the added MSTest item to configure it.
-
In the Assembly file name, specify the path to your compiled test assembly (.dll). Leave the Configuration file name empty.
This configuration will run all the tests in the specified test assembly.
-
Go to View | Organize Tests and add the configured MSTest item to your project’s test items. This way your TestLeft tests will be run automatically when you run the TestComplete project.
-
(Optional.) To add other TestLeft test assemblies (.dll) to your TestComplete project, repeat steps 5–8.
-
Run the TestComplete project.
-
The output from the MSTest runner is included in the TestComplete log:
NUnit Tests
TestLeft provides Visual Studio project templates for NUnit 3. You can also create NUnit-based tests from scratch (without using the templates). To run NUnit-based TestLeft tests from TestComplete, you can use TestComplete integration with NUnit.
-
Compile your TestLeft tests to a .dll.
-
In TestComplete, go to Tools | Options | Engines | Unit Testing and specify the path to the NUnit test runner: nunit-console.exe (if you use NUnit 2) or nunit3-console.exe (if you use NUnit 3).
-
Open the TestComplete project where you want to add your TestLeft tests, or create a new project.
-
Add a new project item of the Selenium or Unit Testing type.
-
Add a child item of the NUnit type.
-
Double-click the added NUnit item to configure it.
-
In the Assembly file name, specify the path to your compiled test assembly (.dll).
-
(Optional.) If you want to run specific tests rather than all the tests contained in the assembly, you can filter the tests by using any of these options:
-
Test fixtures – The full name (including the namespace) of the class that contains the tests to run. You can specify multiple class names separated by semicolons. For example, MyTests.LookupTests;MyTests.ConstraintTests.
-
Include categories and Exclude categories – Comma-separated lists of the test categories to include in or exclude from the test run. For example, BaseLine,Database. Note that category expressions (such as A+B|C) are not supported.
-
-
(Optional.) By default, the NUnit output is added to the TestComplete test log. If you also need the results file in the NUnit format (XML), select Save results to XML file and specify the file name and path.
-
Go to View | Organize Tests and add the configured NUnit test to your project’s test items. This way your TestLeft tests will be run automatically when you run the TestComplete project.
-
(Optional.) To add other TestLeft test assemblies (.dll) to your TestComplete project, repeat steps 5–10.
-
Run the TestComplete project.
-
The output from the NUnit test runner is included in the TestComplete log:
Executable Files
If you compiled your TestLeft test to an executable (for example, .exe or .jar), you can run it from TestComplete scripts and keyword tests as any other application.
One way is to add your executable file to the TestedApps collection in TestComplete and use the TestedApps.AppName.Run()
scripting method or the Run TestedApp keyword test operation. Note that this just launches the executable, but does not wait for it to close.
VBScript
Call TestedApps.WebOrdersTests.Run
JavaScript, JScript
TestedApps.WebOrdersTests.Run();
Python
TestedApps.WebOrdersTests.Run();
DelphiScript
TestedApps.WebOrdersTests.Run();
C#Script
TestedApps["WebOrdersTests"]["Run"]();
Another way is to use the Sys.OleObject("WScript.Shell").Run(path)
method. The sample code below both runs an executable and waits for it to close.
VBScript
Call Sys.OleObject("WScript.Shell").Run("C:\Tests\WebOrdersTests.exe", 1, True)
JavaScript, JScript
Sys.OleObject("WScript.Shell").Run("C:\\Tests\\WebOrdersTests.exe", 1, true);
Python
Sys.OleObject["WScript.Shell"].Run("C:\Tests\WebOrdersTests.exe", 1, true)
DelphiScript
Sys.OleObject('WScript.Shell').Run('C:\Tests\WebOrdersTests.exe', 1, true);
C#Script
Sys["OleObject"]("WScript.Shell")["Run"]("C:\\Tests\\WebOrdersTests.exe", 1, true);
Other Ways of Integrating With TestComplete
TestLeft can connect to remote TestComplete instances and use them to interact with the applications that are running on those remote computers. For details, see Running TestLeft Tests on Remote Computers.
See Also
Running TestLeft Tests
Running TestLeft Tests From Unit Testing Frameworks
Running TestLeft Tests on Remote Computers