【问题标题】:How to get TeamCity to run tests using MSTest?如何让 TeamCity 使用 MSTest 运行测试?
【发布时间】:2012-01-13 00:50:31
【问题描述】:

我想弄清楚如何让 TeamCity 运行我的 MSTest。我已经使用以下参数设置了构建步骤:

  • 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”。不过,如果能在构建日志中得到这样的效果,那就太好了。

【问题讨论】:

  • @Leslie Hanks 答案中的哪些步骤解决了您的问题?
  • @wal 好吧,我的程序集名称有误。
  • 我也是一个白痴,错过了程序集名称中的“s”。值得三重检查:)

标签: .net continuous-integration teamcity mstest


【解决方案1】:

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

即

您的相对路径: 项目\Metadude..Tests\bin\Debug\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%'

我不记得为什么我这样做了,但会有一个很好的理由(比如使用他们的变量时它不起作用)

【讨论】:

  • 首先,确保您尝试测试的程序集存在于该位置。 与@wal 一样,正是程序集名称吸引了我。在我的情况下,程序集名称与项目名称不同......假设。顺便说一句:TC/MSTest 不会记录任何其他内容。
  • 从 Visual Studio 2012(至少是 express 版本)开始,MsTest.exe 被称为vstest.console.exe,可以在C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe找到
  • TeamCity 很智能,不需要 mstest.exe 的完整路径。
  • @qub1n 至少有 16 人不同意 ??
  • 无论如何它对我有用(TeamCity 8.1.3)。 Windows cmd 中的 MStest.exe 无法识别,但 Teamcity 只能使用 MSTEST.EXE。我已经安装了 Windows 7 SDK + Build Tools。
猜你喜欢
  • 1970-01-01
  • 2011-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-25
相关资源
最近更新 更多