How to get TeamCity to run tests using MSTest?

南楼画角 提交于 2019-12-03 11:00:39

问题


I am trying to figure out how to make TeamCity run my MSTests. I have setup a build step using the following parameters:

  • 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

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\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

I have tried to specify the tests to run using the following:

  • Tests: 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.

UPDATE Ok, 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.


回答1:


Firstly, Ensure the assembly you are trying to test exists at that location.

ie

your relative path: 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 MSTest without any arguments somehow.

If you are sure the path is correct try it without specifying the .testsettings file 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

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

instead of their variable '%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)



来源:https://stackoverflow.com/questions/8382632/how-to-get-teamcity-to-run-tests-using-mstest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!