In TestComplete, you can run JUnit and TestNG unit tests and Selenium tests created by using JUNit and TestNG testing framework as part of your TestComplete project. In the Java Unit Test editor, you configure the tests to be run.
To learn about TestComplete support for third-party unit testing frameworks, see:
To learn about TestComplete support for Selenium WebDriver tests, see:
To run JUnit and TestNG tests in TestComplete:
Specify the full path to the Java Virtual Machine executable (java.exe) in the Unit Testing Options dialog.
If you want to use Maven to run your tests, the Maven modules must be installed and configured on your computer. For information on how to do this, see the Maven documentation.
To run Selenium tests, make sure that your computer and TestComplete project meet the requirements described in Integration With Selenium - Prerequisites.
1. Prepare Your Test Machine, TestComplete and Tests
Make sure that the computer where you will run tests, TestComplete and your tests are prepared for testing.
To learn how to prepare Selenium tests for testing, see –
Copy your test files to your TestComplete computer.
2. Configure Your TestComplete Project
Open your TestComplete test project or create a new one.
Add a Selenium or Unit Testing collection to your test project. See Adding and Removing Project Items and Their Child Elements.
Add a JUnit item or the TestNG item to the created collection.
Added JUnit Item
Added TestNG Item
3. Configure the Added Item to Run Needed Tests
Select how you will run your tests:
To run your tests by using Maven, select Use Maven project.
Enter the path to the Maven project configuration file (pom.xml) or click the ellipsis button and browse for the needed file in the subsequent dialog.
Run JUnit Tests by Using Maven
Run TestNG Tests by Using Maven
To run your tests using the classpath, select Specify the classpath directly.
Enter not only your tests' classpaths, but also the paths to all modules and libraries your tests use:
For JUnit tests, the path to the junit-n.nn.jar file. For example, C:\JUnit\junit-4.12.jar.
For TestNG tests, the path to the testng-n.n.n.jar file. For example, C:\TestNG\testng-6.8.8.jar.
The paths to the classes that define tests to run.
Note: The full path to a Java class file (.class) reflects the class’s package name. For example, the
com.smartbear.seltest.AppTestClassclass is in the <classes>\com\smartbear\seltest folder.
The class path is the name of the top-level folder that contains folders whose names indicate to which package they belong. In this case, the class path is <classes>.
For example, if the files that define your test classes are in the C:\JUnitSeleniumTests\target\classes folder, specify the path to that folder.
For Selenium tests, the paths to the Selenium modules that your tests use. For example, C:\Selenium\selenium-java-2.43.1.jar.
The paths to the classes that your tests use.
The examples below demonstrate how you can specify a classpath:
Run JUnit Tests by ClasspathC:\JUnit\junit-4.12.jar;C:\JUnit\hamcrest-core-1.3.jar;C:\Tests\SeleniumJUnitTests\target\classes;C:\Selenium\selenium-java-2.43.jar;
Run TestNG Tests by ClasspathC:\TestNG\testng-6.8.8.jar;C:\Tests\SeleniumTestNGTests\target\classes;C:\Selenium\selenium-java-2.43.jar;
Specify the test classes you want to run:
To run all the test classes defined in your test, select Run all tests. Note that this mode is available only if you run your tests by using Maven.
To run only specific test classes, select Run the following test classes. In the test list, enter the test classes to run.
JUnit Test Classes to Run
TestNG Test Classes to Run
To add a test class to the list, click Add and enter the needed test class name. For example,
Tip: If you do not know the test class names, contact the developer who created the test. As an alternative, you can explore the source files of your tests and find all the classes whose methods use the
To remove the selected test class from the list, click Remove. To temporary exclude a test class from a test run, clear the check box next to the test class name in the list.
4. Run the Test Item
Run the test item in TestComplete. For information on how to run unit test items, see Running Unit Tests.
TestComplete will command the appropriate unit testing framework to run the specified tests.
After the test run is over, view the test results.
JUnit Test Results
TestNG Test Results