Running TestComplete Tests From MSBuild Projects

Applies to TestComplete 14.93, last modified on September 16, 2021

You can run TestComplete tests as part of your Microsoft Build Engine (MSBuild) projects. TestComplete provides the MSBuildTC14Task.dll assembly describing the tasks that run TestComplete tests.

Requirements

Your computer must have Microsoft .NET Framework 2.0–3.5 installed. TestComplete supports MSBuild included in these versions.

TestComplete installation program will install and register the MSBuildTC14Task.dll assembly in the global assembly cache (GAC) automatically.

Example

Below is a typical example of running a TestComplete project suite from an MSBuild project:

XML

<!-- File: MSBUILD.proj -->

  
<!-- Root element of the MSBuild project -->
<Project DefaultTargets="Build"
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 
  <!-- Declares the task type, ExecuteSolution, that will be used to run TestComplete projects (TC14 is a namespace). --> 
  <UsingTask TaskName="TC14.ExecuteSolution" AssemblyName= "MSBuildTC14Task, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=e33f56e68d0f845e"/>
 
  <!-- Target -->
  <Target Name="Build">
 
  <!-- Executes the task. Note that the tag name, ExecuteSolution, coincides with the registered task name.   -->
    <ExecuteSolution
      SolutionFile="C:\MyProjects\MyProjectSuite.pjs"
      StopIfFail="true"
      AdditionalOptions="/project:MyProject"
      GUIInteractive="true"
      LogFile="C:\MyProjects\MyResults.mht"
    />
  </Target>
</Project>

The example is simple, but it demonstrates two key points of executing a TestComplete project suite from an MSBuild project:

  • Registration. To run a TestComplete project suite from MSBuild projects, you should register a special task type. The registration is done via the UsingTask element whose attributes specify the task name and the name of the assembly that will perform the task. You should always register the task type before using it in an MSBuild project. The registration string should always be the same as it is specified in the sample. You can copy the UsingTask string and paste it to your MSBuild project file. Do not modify this string in your MSBuild project file.
  • Execution. Upon registering the task type, you can use the ExecuteSolution element to run the needed TestComplete project suite. The UsingTask element associates ExecuteSolution with the assembly that will perform the task. The attributes of ExecuteSolution specify run parameters:
    Attribute Description
    SolutionFile [in] The full path and name of the project suite file to run.
    StopIfFail [in] Indicates whether MSBuild run will fail if TestComplete task run fails.
    AdditionalOptions [in] A string of command-line arguments passed to TestComplete along with the project suite file name. For more information on supported command-line arguments, see TestComplete Command Line.
    GUIInteractive [in] Indicates whether TestComplete ("true") or TestExecute ("false") will run tests.
    LogFile [in] The full path and name of the .MHT file to which TestComplete will export test results. The results are always exported to files of the Multipart HyperText (MHT) format. You can view these files in Microsoft Internet Explorer.

See Also

Integration With Microsoft Visual Studio and Azure DevOps

Highlight search results