Running PyUnit Tests and Selenium Tests Created With PyUnit

Applies to TestComplete 15.47, last modified on January 20, 2023

PyUnit is a standard unit test framework for Python.

In TestComplete, you can run Python unit tests and Selenium tests created by using the PyUnit testing framework as part of your TestComplete project. In the PyUnit Test editor, you configure the tests to be run.

To learn about TestComplete support for third-party unit testing frameworks, see —

Integration With Unit Testing Frameworks

To learn about TestComplete support for Selenium WebDriver tests, see —

Integration With Selenium

Requirements
  • To run the PyUnit tests, specify the path to the Python executable (python.exe) in the Unit Testing Options dialog.

    To open the dialog, select Tools | Options from the TestComplete main menu and then select Engines | Unit Testing in the resulting Options dialog.

  • 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 –

    Integration With Selenium - Prerequisites

  • Copy your PyUnit test files to your TestComplete computer.

2. Configure Your TestComplete Project
3. Configure the PyUnit Item to Run Needed Tests
  • In Module, enter the path to your Python module (.py) that contains needed tests. You can click the ellipsis button and browse for the Python module in the subsequent dialog.

  • Select the mode you want to use to run tests:

    • To run all tests defined in your Python module, select Run all tests from the module in the Modes section.

    • To run only specific tests, select Run specified tests in the Modes section.

      On the Tests list, specify the tests you want to run. To add a test, click Add and enter the test routine name. For example, test1 or TestCaseClass1.test1.

      To run all test methods defined in a test case, enter the test case class name, for example, TestCaseClass1.

      To remove a selected test from the list, click Remove. To temporary exclude a test from a test run, clear the check box next to the test name in the list.

    PyUnit Selenium test properties
4. Run the PyUnit Test Item

Run the PyUnit test item in TestComplete. For information on how to run unit test items, see Running Unit Tests.

TestComplete will command PyUnit to run the specified tests.

After the test run is over, view the test results.

Selenium test results

See Also

Integration With Unit Testing Frameworks
Running Unit Tests
Integration With Selenium
Unit Testing Options Dialog

Highlight search results