【问题标题】:TeamCity Visual Studio Tests build step to run single testTeamCity Visual Studio 测试构建步骤以运行单个测试
【发布时间】:2019-03-11 17:25:41
【问题描述】:

我有一个带有测试项目的 Visual Studio 解决方案,例如:

MySolution.sln
MyProject.csproj
MyProject.Tests.csproj

在 TeamCity 中,可以很容易地创建一个类型为 Visual Studio Tests 的构建步骤,该步骤针对在 MyProject.Tests.dll 中找到的所有测试(带有 [TestMethod][DataTestMethod] 的测试)。

我已经进行了一些谷歌搜索,但我没有找到如何仅按名称运行特定测试 - 类似于 Visual Studio 右键单击​​测试名称并运行测试。

有人知道这是否可行吗?

【问题讨论】:

    标签: visual-studio unit-testing teamcity visual-studio-test-runner


    【解决方案1】:

    TeamCity 在后台使用 VSTest.Console.exe 运行测试。所以基本上,您可以使用此处列出的参数:https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2017,来决定应该运行哪些测试。

    在 TeamCity 界面中,有一个字段Test Names。使用此字段指定要运行的测试:

    这会给你这样的东西:

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

    【讨论】:

    • 我的VSTest 2017 build-step UI 在您的屏幕截图中没有任何低于Test file names 的内容。你运行的是什么版本的TeamCity Server
    • TeamCity 2018.2.1(内部版本 61078)。默认情况下,此选项可能是隐藏的。在您的构建步骤中单击Show advanced options。这是链接做文档:confluence.jetbrains.com/display/TCD18/…
    猜你喜欢
    • 1970-01-01
    • 2013-02-21
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 1970-01-01
    相关资源
    最近更新 更多