21

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.

Leslie Hanks
  • 2,347
  • 3
  • 31
  • 42

1 Answers1

20

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)

Jim Aho
  • 9,932
  • 15
  • 56
  • 87
wal
  • 17,409
  • 8
  • 74
  • 109
  • _Firstly, Ensure the assembly you are trying to test exists at that location._ As with @wal, it was the assembly name that got me. In my case the assembly name differed from the project name... assumptions. BTW: Nothing else gets logged by TC/MSTest. – Campey Mar 06 '12 at 07:30
  • 6
    Since Visual Studio 2012 (at least the express versions) MsTest.exe is called `vstest.console.exe` and can be found at `C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe` – dwonisch Nov 14 '13 at 21:03
  • TeamCity is smart and full path to mstest.exe is not needed. – Tomas Kubes Sep 24 '14 at 12:32
  • 1
    @qub1n at least 16 people disagree ?? – wal Sep 24 '14 at 12:34
  • Anyway it works for me (TeamCity 8.1.3). MStest.exe in windows cmd is not recognized, but Teamcity just work with only MSTEST.EXE. I have installed Windows 7 SDK + Build Tools. – Tomas Kubes Sep 24 '14 at 14:50
  • If you don't want to install visual studio, you can install visual studio test agent, vstest.console.exe is found in the same path. – CularBytes Mar 11 '17 at 11:09