Running Unit Tests

Applies to TestComplete 12.60, last modified on September 17, 2018

In TestComplete, you can run a unit test in various ways. This topic describes them.

Running From the Project Explorer

Selenium or Unit Testing collections in Project Explorer contain all unit tests in your project. To run a test:

  • Right-click the needed test in Project Explorer.

  • Choose Run Test_Name from the context menu:

    Running Unit Tests From TestComplete UI

Running From Scripts

To run a unit test from scripts, call the UnitTest.Execute method:

JavaScript, JScript

SeleniumTests.JUnitTest1.Execute();

Python

SeleniumTests.JUnitTest1.Execute()

VBScript

SeleniumTests.JUnitTest1.Execute

DelphiScript

SeleniumTests.JUnitTest1.Execute;

C#Script

SeleniumTests["JUnit1"]["Execute"]();

In the example above, SeleniumTests is a sample name of a Selenium or Unit Testing collection, to which your “unit test” item - JUnit1 - belongs:

Running Unit Tests From Scripts

In your project, the names can differ. For instance, you may have SeleniumTests.PyUnit2.Execute() or UnitTests1.NUnit1.Execute().

Running From Keyword Tests

To run a unit test from a keyword test, use the Call Object Method or Run Code Snippet operation to call the Execute method.

Running Unit Tests From Scripts

Running As Project Test Items

  • Select your project in Project Explorer and then select View | Organize Tests from the TestComplete main menu. This will open the Test Items page of the project editor.

  • Drag the desired unit test to the Test Items editor.

  • Save the changes by selecting File | Save from the TestComplete main menu.

    Running Unit Tests as Test Items

When you run your project, TestComplete will run your unit tests.

Viewing the Test Log

After the test run is over, TestComplete will show a test log. The Additional Information panel of the test log will contain the command-line output produced by the appropriate unit testing framework.

If you use the MSTest unit testing tool, the TestComplete test log will report the test results in a specific format. See MSTest Log.

See Also

Integration With Unit Testing Frameworks - Overview
Tests and Test Items
Integration With Selenium

Highlight search results