Running TestComplete Automated Tests From MSBuild Projects

Author: SmartBear Software
Applies to: TestComplete 10


TestComplete currently has a flawless integration with MSBuild that allows you to run TestComplete’s automated software tests during the local build process initiated by MSBuild.

You can execute TestComplete project suites, projects and automated tests as part of your MSBuild projects. This allows you to build your application with MSBuild and automatically perform various automated testing actions at the same time with the help of TestComplete. By using this functionality in your MSBuild projects, you can build your applications and achieve all of the benefits provided by TestComplete’s software testing: working with applications via the user interface and simulating various user actions, accessing the internal structure of applications, unit testing and a lot more.

Note that you can integrate TestComplete with MSBuild and use the features provided by TestComplete to automate testing of your application during the build process initiated by MSBuild regardless of which TestComplete module you have installed (Desktop, Web or Mobile).

Note that only the TestComplete Enterprise edition can be integrated with MSBuild and provides features for automated testing of applications during the build process initiated by MSBuild.

Integrating Automated Tests With MSBuild

To use the functionality of TestComplete in your MSBuild projects, you should integrate TestComplete with MSBuild. When installing TestComplete on your computer, select the MSBuild Integration item in the installation wizard:

Setting up TestComplete and MSBuild Integration

If you select this item, the package needed for integration will be installed on your computer. This package includes an assembly named MSBuildTC10Task.dll. The installation program automatically registers this assembly in the global assembly cache (GAC). Note that the package can be installed only on a computer that has Microsoft .NET Framework 2.0.50727 or higher installed.

Executing Automated Tests From MSBuild Projects

MSBuild projects are stored in XML files that use the MSBuild XML schema and instruct the build engine to perform operations during the build process and how these operations should be performed.

By using the MSBuild project format, you can extend your local builds with advanced actions that are performed during the automated build process. For instance, you can perform various automated testing operations after the build has finished. The MSBuild Integration package of TestComplete enables you to execute TestComplete project suites from your MSBuild project and perform various automated tests during the automated build process.

The most important type of elements in MSBuild projects are tasks that are used by MSBuild to perform build operations. For example, a task can compile source files, run external tools, create and remove files and directories, log errors, warnings, messages and more. Tasks are grouped by the Target elements that specify the logical structure of the build process and the proper order of tasks.

To run TestComplete’s project suites from MSBuild projects, the MSBuild Integration package provides the ExecuteSolution task type. Using this MSBuild project element, you can execute TestComplete solutions, single projects or even project items during the automated build process. Below is an example of executing a TestComplete project suite from an MSBuild project:

<!-- File: MSBUILD.proj -->
<!-- Root element of the MSBuild project -->

<Project defaulttargets=“Build” xmlns=“”>

<!-- Declares the task type, ExecuteSolution, that will be used to run TestComplete projects (TC10 is a namespace). -->
<UsingTask TaskName="TC10.ExecuteSolution" AssemblyName="MSBuildTC10Task, Version=, Culture=neutral,

<!-- Target -->
<Target Name=“Build”>

<!-- Executes the task. Note that the tag name, ExecuteSolution, coincides with the registered task name. -->

The example is simple, but it demonstrates the key points of executing a TestComplete project suite from an MSBuild project. To run TestComplete project suites from your build project, you should do the following:

  1. Register the ExecuteSolution task type. This task type allows you to execute a TestComplete project suite. You should always register this task type before using it in MSBuild projects, because it is a custom task type. You can register it via the UsingTask element. Its TaskName attribute specifies the task name, and the AssemblyName attribute specifies the name and properties of the assembly that will perform the task. This attribute should specify the MSBuildTC10Task.dll assembly that is part of the MSBuild Integration package. To learn what registration parameters are used for other versions of TestComplete, see the "Running TestComplete Tests From MSBuild Projects" topic in the documentation shipped with the appropriate TestComplete version.

  2. Call the ExecuteSolution task. Upon registering the task type, you can use it to specify the desired TestComplete project suite and initiate its execution from your MSBuild project. The ExecuteSolution element has a number of attributes that specify the TestComplete project suite’s run parameters:

    Attribute Description
    SolutionFile The full path and name of the TestComplete project suite to be executed.
    StopIfFail Indicates whether the build will fail (“true”) or not (“false”), if the TestComplete task run fails.
    AdditionalOptions A string with command-line arguments that are passed to TestComplete along with the project suite file name. Via these arguments you can specify, for example, the project name, the project item or even the name of the routine to be executed. So, it is possible to execute not only the whole project suite, but even its items.
    GUIInteractive Indicates whether TestComplete (“true”) or TestExecute (“false”) should be used to run tests.
    LogFile The full path and name of the .MHT (Multipart HyperText) file. TestComplete exports test results to this file.

Via command-line arguments (the AdditionalOptions attribute of the ExecuteSolution MSBuild project element) you can specify the names of TestComplete projects, project items, units and script routines to be executed from your MSBuild project. Below is the description of the most important combinations of command-line arguments:

/project:project_name – specifies the name of the project to be run.

/project:project_name /projectitem:item_name – TestComplete will run automated tests provided by the specified project item.

/project:project_name /unit:unit_name /routine:routine_name – TestComplete will run the specified script routine declared in the specified script unit.

If command-line arguments do not exist in the AdditionalOptions attribute, TestComplete will run the whole project suite specified by the SolutionFile attribute.

Creating and Building MSBuild Projects

Since MSBuild projects are written in XML, you can create, view and edit them in any XML editor or even in a text editor (for example, in Notepad). Note that Visual Studio project files (for instance, .csproj or .vbproj files) are also MSBuild project files and use the MSBuild XML schema. So, it is easy to view and edit MSBuild project files in Visual Studio by using its built-in XML Editor.

To create and modify MSBuild project files, you can use another SmartBear product – Automated Build Studio. This powerful tool in addition to all of its capabilities provides an easy way to create and edit your MSBuild project files. By using its intuitive user interface, you can quickly and easily create and edit your MSBuild projects. You don’t need to write XML code! Just use the desired project elements provided by Automated Build Studio to construct your MSBuild project and it will create an appropriate XML file.

To execute MSBuild projects, use the MSBuild.exe utility. Note that Visual Studio uses a hosted instance of MSBuild to execute managed build projects. You can also run your MSBuild projects directly in Visual Studio and execute TestComplete’s automated tests during the build process.


As you can see, TestComplete’s integration with MSBuild allows you to run TestComplete automated tests as part of MSBuild projects and perform various automated testing actions during the application build process. We hope this article will be useful and the information it contains will help you extend your team builds with TestComplete automated tests making your builds more flexible and even more powerful. If you are new to TestComplete, download now and try TestComplete for free.