.net 如何让 TeamCity 使用 MSTest 运行测试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8382632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get TeamCity to run tests using MSTest?
提问by Leslie Hanks
I am trying to figure out how to make TeamCity run my MSTests. I have setup a build step using the following parameters:
我想弄清楚如何让 TeamCity 运行我的 MSTest。我使用以下参数设置了构建步骤:
- Path to MSTest.exe:%system.MSTest.10.0%
- List assembly files:Projects\Metadude..Tests\bin\Debug\Metadude..Test.dll
- MSTest run configuration file:Local.testsettings
- MSTest.exe 的路径:% system.MSTest.10.0%
- 列出程序集文件:Projects\Metadude。.Tests\bin\Debug\Metadude。.Test.dll
- MSTest 运行配置文件:Local.testsettings
However when this step runs, it does not execute any tests. This is the output from the log:
但是,当此步骤运行时,它不会执行任何测试。这是日志的输出:
[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\workf82da3df0f560b6
[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
I have tried to specify the tests to run using the following:
我尝试使用以下命令指定要运行的测试:
- Tests:Tests.Metadude.Core.Extensions.StringExtensionsTests
- 测试:Tests.Metadude.Core.Extensions.StringExtensionsTests
But that doesn't work. I can't seem to find any documentation on google related to the MSTest build step in TeamCity.
但这不起作用。我似乎无法在 google 上找到任何与 TeamCity 中的 MSTest 构建步骤相关的文档。
UPDATEOk, I am an idiot. Well that might be a little harsh, but the test assembly was missing an "s" from the assembly name. Would have been nice to get something to that effect in the build log though.
更新好吧,我是个白痴。好吧,这可能有点苛刻,但是测试程序集的程序集名称中缺少一个“s”。不过,如果能在构建日志中获得某种效果,那就太好了。
采纳答案by wal
Firstly, Ensure the assembly you are trying to test exists at that location.
首先,确保您尝试测试的程序集存在于该位置。
ie
IE
your relative path: Projects\Metadude..Tests\bin\Debug\Metadude..Test.dll
您的相对路径:Projects\Metadude..Tests\bin\Debug\Metadude..Test.dll
However I would expect something logged by TC if your file didnt exist. It looks like its running MSTestwithout any arguments somehow.
但是,如果您的文件不存在,我希望 TC 记录一些内容。看起来它MSTest以某种方式在没有任何参数的情况下运行。
If you are sure the path is correct try it without specifying the .testsettingsfile to see what happens. I'm using MSTest succesfully in TC without this (but you may need it). The other thing I'm doing different is I specify the FULL path to MSTest.exe, ie
如果您确定路径正确.testsettings,请在不指定文件的情况下尝试看看会发生什么。我在没有这个的情况下成功地在 TC 中使用了 MSTest(但你可能需要它)。我做的另一件事是我指定了 FULL 路径MSTest.exe,即
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe
instead of their variable '%system.MSTest.10.0%'
而不是他们的变量 '%system.MSTest.10.0%'
I can't recall why I did this but there would have been a good reason (like it didnt work when using their variable)
我不记得我为什么这样做了,但是有一个很好的理由(比如在使用他们的变量时它不起作用)

