JetBrains / TeamCity.VSTest.TestAdapter

Apache License 2.0
30 stars 14 forks source link

Test Adapter for

NuGet TeamCity.VSTest.TestAdapter License

Provides the TeamCity integration with test frameworks via the Visual Studio Test Platform or VSTest IDE tools.

It is important to note that the above demo works from the command line when the environment variable TEAMCITY_VERSION exists with any value during dotnet commands. TeamCity automatically specifies this environment variable by the current TeamCity version for each build step.

Supported platforms:

Visual Studio Test Platform

Presently, Visual Studio has an open and extensible test platform with tests written using various test frameworks and run using a variety of adapters. The Test Platform, from its vantage, resolves the lifecycle of the test into a series of stages – two of which are writing and running the test – with the goal of providing extensibility at each stage.

For each test project:

Alternatively to two steps above, you could create the a test project from the command line using the specified template:

   dotnet new mstest

or

   dotnet new xunit

Thus, the final project file could look like the following:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>    
    <TargetFrameworks>net45;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>    
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
    <PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
    <PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.15" />    
  </ItemGroup>  
</Project>

VSTest Console

For example:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" dotNet.XUnit.Tests.dll /Logger:teamcity /TestAdapterPath:.

VSTest extensions

Visual Studio Content directory Target directory
2019 vstest15 PROGRAM_FILES(x86)\Microsoft Visual Studio\2019\\Common7\IDE\Extensions\TestPlatform\Extensions
2017 update 5 onwards vstest15 PROGRAM_FILES(x86)\Microsoft Visual Studio\2017\\Common7\IDE\Extensions\TestPlatform\Extensions
2017 till update 4 vstest15 PROGRAM_FILES(x86)\Microsoft Visual Studio\2017\\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions
2015 vstest14 PROGRAM_FILES\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions
2013 vstest12 PROGRAM_FILES\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions
2012 vstest12 PROGRAM_FILES\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions

See more details in the Wiki.

See the article for details on how to create tests using the Visual Studio Test Platform.

Docker Container Support

To run tests from within a Docker container that is hosted on a machine running the TeamCity agent, the container must have a TEAMCITY_PROJECT_NAME or TEAMCITY_VERSION environment variable set. Example:

docker run --rm -v $PWD:/app -w /app -e TEAMCITY_VERSION microsoft/dotnet:2.1-sdk dotnet test

Known issues