Running TestLeft Tests From TestComplete

Applies to TestLeft 15.40, last modified on March 17, 2022

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:

  1. Compile your TestLeft tests or create a Maven project.

  2. In TestComplete, go to Tools > Options > Engines > Unit Testing and specify the path to the Java Virtual machine:

    The Java Virtual Machine path in TestComplete options
  3. Open the TestComplete project where you want to add your TestLeft tests, or create a new project.

  4. Add a new Unit Testing collection to the project:

    The Unit Testing collection in a TestComplete project
  5. Depending on the unit testing framework you have used to create your TestLeft tests, add a new JUnit or TestNG item to the collection:

    Add a TestNG item or a JUnit Test item to your project
  6. 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):

      Specify the Maven project file
    • 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.

      Specify the classpath

      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\*
  7. Specify the test classes you want to run:

    Specify the test classes to run
  8. 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.

  9. 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.

  1. Compile your TestLeft tests to a .dll. This is the default output type when using TestLeft’s Visual Studio project templates.

  2. 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.

    mstest.exe path in TestComplete options
  3. Open the TestComplete project where you want to add your TestLeft tests, or create a new project.

  4. Add a new project item of the Selenium or Unit Testing type.

  5. And a child item of the MSTest type.

    Adding an MSTest item to the TestComplete project
  6. Double-click the added MSTest item to configure it.

  7. 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.

    Configuring the MSTest item to run TestLeft tests
  8. 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.

  9. (Optional.) To add other TestLeft test assemblies (.dll) to your TestComplete project, repeat steps 5–8.

  10. Run the TestComplete project.

  11. The output from the MSTest runner is included in the TestComplete log:

    MSTest unit test log in TestComplete

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.

  1. Compile your TestLeft tests to a .dll.

  2. 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).

    NUnit path in TestComplete options
  3. Open the TestComplete project where you want to add your TestLeft tests, or create a new project.

  4. Add a new project item of the Selenium or Unit Testing type.

  5. Add a child item of the NUnit type.

    Adding an NUnit item to a TestComplete project
  6. Double-click the added NUnit item to configure it.

  7. In the Assembly file name, specify the path to your compiled test assembly (.dll).

    Configuring the NUnit item to run TestLeft tests
  8. (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.

  9. (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.

  10. 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.

  11. (Optional.) To add other TestLeft test assemblies (.dll) to your TestComplete project, repeat steps 5–10.

  12. Run the TestComplete project.

  13. The output from the NUnit test runner is included in the TestComplete log:

    NUnit test log in TestComplete

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

Highlight search results