如何让TeamCity使用MSTest运行测试?

时间:2011-12-05 08:26:26

标签: .net continuous-integration teamcity mstest

我正在试图弄清楚如何让TeamCity运行我的MSTests。我使用以下参数设置了构建步骤:

  • MSTest.exe的路径:%system.MSTest.10.0%
  • 列出程序集文件: Projects \ Metadude。 .Tests \ bin \ Debug \ Metadude。 .Test.dll
  • MSTest运行配置文件: Local.testsettings

但是,当此步骤运行时,它不会执行任何测试。这是日志的输出:

[02:13:49]: Step 2/2: Run Unit Tests (MSTest)
[02:13:49]: [Step 2/2] Starting: "D:\Program Files (x86)\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe" #TeamCityImplicit
[02:13:49]: [Step 2/2] in directory: D:\Program Files (x86)\TeamCity\buildAgent\work\1f82da3df0f560b6
[02:13:50]: [Step 2/2] Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
[02:13:50]: [Step 2/2] Copyright (c) Microsoft Corporation. All rights reserved.
[02:13:50]: [Step 2/2]
[02:13:50]: [Step 2/2] Please specify tests to run, or specify the /publish switch to publish results.
[02:13:50]: [Step 2/2] For switch syntax, type "MSTest /help"
[02:13:50]: [Step 2/2] Process exited with code 1
[02:13:50]: Publishing internal artifacts
[02:13:50]: [Publishing internal artifacts] Sending build.finish.properties.gz file
[02:13:50]: Build finished

我尝试使用以下命令指定要运行的测试:

  • 测试: Tests.Metadude.Core.Extensions.StringExtensionsTests

但这不起作用。我似乎无法在Google上找到与TeamCity中的MSTest构建步骤相关的任何文档。

更新 好吧,我是个白痴。好吧,这可能有点苛刻,但测试组件缺少程序集名称中的“s”。本来很高兴在构建日志中获得这样的效果。

1 个答案:

答案 0 :(得分:20)

首先,确保您尝试测试的程序集存在于该位置。

你的相对路径:  项目\ Metadude..Tests \ BIN \调试\ Metadude..Test.dll

但是,如果您的文件不存在,我会期望TC记录的内容。看起来它的运行MSTest没有任何参数。

如果您确定路径正确,请在不指定.testsettings文件的情况下尝试,以查看会发生什么。我在没有这个的情况下在TC中成功使用MSTest(但你可能需要它)。我正在做的另一件事是我指定MSTest.exe的完整路径,即

  

C:\ Program Files \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ MSTest.exe

而不是变量'%system.MSTest.10.0%'

我不记得为什么我这样做但是有一个很好的理由(就像它在使用变量时没有用)