Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get TeamCity to run tests using MSTest?

Tags:

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.

like image 707
Leslie Hanks Avatar asked Dec 05 '11 08:12

Leslie Hanks


Video Answer


1 Answers

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)

like image 99
wal Avatar answered Oct 24 '22 10:10

wal