简体   繁体   中英

TeamCity Visual Studio Tests build step to run single test

I have a Visual Studio solution with test projects , for example :

MySolution.sln
MyProject.csproj
MyProject.Tests.csproj

In TeamCity it's easy to create a build step of type Visual Studio Tests that targets all tests found in MyProject.Tests.dll ( those notated with [TestMethod] and [DataTestMethod] ).

I've done some Googling but I'm not finding how to run only a specific test by name - similar to Visual Studio right-click on test name and run tests.

Does anyone know if this is possible ?

TeamCity uses VSTest.Console.exe under the hood to run tests. So basically, you can use params listed in here: https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2017 , to decide, which tests should be run.

In TeamCity interface, there is a field Test Names . Use this field to specify tests to run:

TeamCity测试配置

This will give you something like this:

vstest.console.exe path\to\tests.assembly.dll /Tests:TestClass.TestName1,TestClass.TestName2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM