2. Prepare Visual Studio Test Projects for Running TestComplete Tests (Run TestComplete Tests as Part of Release Pipeline)

Applies to TestComplete 14.10, last modified on June 5, 2019

To run your TestComplete tests when deploying your releases, create a Visual Studio test project that will store your TestComplete tests.

Why Preparing Projects Is Needed

Visual Studio test projects store a relative path to TestComplete projects or project suites to be run.

When you build your project on a build computer, TestComplete Test item files (.tctest) will be copied to the build output folder. However, TestComplete project files (.pjs, .mds and etc.) will not be copied to the output folder because they do not belong to the Visual Studio test project:

TestComplete integration with Visual Studio: Why configuration is needed

Click the image to enlarge it.

The path to the TestComplete project that the TestComplete Test item stores may become invalid. During the test run, your Visual Studio test project will not be able to find the needed TestComplete project or project suite and the tests will fail.

To avoid this issue, make sure that the path, which the Visual Studio test projects store, corresponds to the actual location of your TestComplete projects.

You can create custom build steps to copy your TestComplete project suite files to a proper folder and keep the path valid. In this topic, we will describe how to create such build steps.

Requirements

To create and configure a Visual Studio test project and include your TestComplete tests in it, you must have the following software installed:

  • One of the following Microsoft Visual Studio versions with Team Explorer component:

    • Microsoft Visual Studio 2015–2019 (Community, Enterprise or Professional edition).

    • Microsoft Visual Studio 2013 (Community, Ultimate, Premium, or Professional edition).

    • Microsoft Visual Studio 2010–2012 (Ultimate, Premium, or Professional edition).

  • TestComplete 14.

  • TestComplete 14 Visual Studio Integration Package.

    The Integration Package installer is shipped along with TestComplete. You can find it in the TestComplete folder after installing the product:

    <TestComplete 14>\VS Integration\VSIntegration.exe

    Run this installer after installing TestComplete on the computer, where you create and configure your test project. In the installation wizard, select the Visual Studio Integration feature appropriate for your Visual Studio version.

1. Add TestComplete Test to Visual Studio Test Project

  1. In Visual Studio, open your Visual Studio test project or create a new one:

    TestComplete integration with Visual Studio: Create a test project in Visual Studio

    Note: You cannot add TestComplete tests to Visual C++ unmanaged (native) test projects. As a workaround, we suggest that you use a test project of any other type (for example, a Visual C++ Managed Test project).

  2. In Solution Explorer, add a new folder to your Visual Studio test project. This is the folder where your TestComplete Test item will be stored:

    TestComplete integration with Visual Studio: Adding a folder that will store TestComplete project files
  3. Right-click the created folder and select Open Folder in Windows Explorer from the context menu. This will open the created folder in Windows Explorer:

    Place your TestComplete project suite with all its files in the folder:

    TestComplete integration with Visual Studio: Placing TestComplete project files to the created folder
  4. In Visual Studio Solution Explorer, add a new TestComplete Test item to the created folder:

    TestComplete integration with Visual Studio: Adding TestComplete Test item to the Visual Studio test project

    Visual Studio will create a new TestComplete test, add it to the test project and display the test in the project item tree of Solution Explorer:

    TestComplete integration with Visual Studio: TestComplete Test item in Visual Studio Solution Explorer
  5. Configure the added TestComplete Test item to run the needed TestComplete tests:

    TestComplete integration with Visual Studio: Configuring TestComplete Test item to run TestComplete tests

    For detailed instructions on how to do it, see Add TestComplete Tests to Visual Studio Test Projects.

  6. If you use Visual Studio 2010, add your TestComplete Test item to a test list:

    TestComplete integration with Visual Studio 2010: Adding TestComplete Test item to a test list

2. Create Custom Build Steps

  1. In Visual Studio Solution Explorer, select your test project and choose Properties from the Project menu.

  2. In the ensuing Project Designer panel, depending on your test project’s language:

    Switch to the Compile tabbed page and click Build Events.

    – or –

    Switch to the Build Events tabbed page.

  3. In Pre-build event command line, enter commands that will clear the TCSuiteFolderName folder in the project’s output folder:

    rd /S /Q "$(TargetDir)TCSuiteFolderName"

    TCSuiteFolderName - The name of the folder in your Visual Studio test project that stores your TestComplete Test item (.tctest) and TestComplete test files. It is the folder you created earlier.

    TestComplete integration with Visual Studio: Folder storing your TestComplete project files

    The TargetDir variable specifies the path to the project’s output folder.

  4. In Post-build event command line, enter commands that will copy your TestComplete project suite files to the project’s output folder:

    md "$(TargetDir)TCSuiteFolderName"
    xcopy "$(ProjectDir)TCSuiteFolderName" "$(TargetDir)TCSuiteFolderName" /Y /E

    The ProjectDir variable specifies the project’s source directory.

3. Configure TestComplete Test Item Properties

  1. In Visual Studio Solution Explorer, right-click the TestComplete Test item and then click Properties.

  2. In the Properties panel, set the Copy to Output Directory property of the TestComplete Test item to Do not copy:

    TestComplete integration with Visual Studio: Configuring TestComplete Test item properties

4. Add Test Project to Source Control System

Azure DevOps and Team Foundation Server work only with files stored in source control. Connect to your team project and add your Visual Studio test project to your team repository:

Git (For Visual Studio 2013–2019)
  1. In Team Explorer, connect to your team project.

  2. Right-click your solution in Solution Explorer and select Add Solution to Source Control from the context menu.

  3. In Team Explorer, click Commit to commit your solution files to the Git repository.

Team Foundation Version Control
  1. In Team Explorer, connect to your team project.

  2. If needed, configure your workspace and map it to the needed folder on your computer.

  3. Make sure that your Visual Studio test project is in the workspace folder.

  4. Right-click your solution in Solution Explorer and select Add Solution to Source Control from the context menu.

    Visual Studio will add the project files to your team project repository.

  5. Right-click the solution node in the Solution Explorer and choose Check In from the context menu or click Check In in the Team Explorer panel.

  6. In the subsequent Check In dialog, click Check In. Visual Studio will check in the solution files to the repository.

5. Add TestComplete Project to Source Control System

Add your TestComplete project suite to the source control you use for your team project:

TestComplete integration with Visual Studio: Add TestComplete project files to source control

We recommend that you do this directly from within the TestComplete IDE (for more information, see Integration With Source Control Systems). This way, only necessary files will be added.

Prev     Next

See Also

Run TestComplete Tests as Part of Release Pipeline
Prepare TestComplete Project for Integration
Create a Build Containing TestComplete Tests

Highlight search results