4

I have read No tests to execute msTest

I'm trying to run a unit test (MS unit tests) from the command line. It's my first time attempting this.

My command works fine (no syntax errors), which is

mstest /testcontainer:C:\Users\me\source\repos\Test03\UnitTestProject1\bin\debug\UnitTestProject1.dll

The problem is I always get the following response in the console

Loading C:\Users\me\source\repos\Test03\UnitTestProject1\bin\debug\UnitTestProject1.dll...
Starting execution...
No tests to execute.

My unit test is simply

namespace UnitTestProject1 { [TestClass] public class UnitTest1 { [TestMethod] public void AddPositive() { var bll = new ConsoleApp1.Bll(); var result = bll.Add(2, 5); Assert.IsTrue(result == 7); } } 

Why does it not find the test as I've followed the instructions from https://msdn.microsoft.com/en-us/library/ms182489.aspx#testcontainer?

The solution as a whole targets 4.6.1 , I'm using VS 2017 Enterprise

6
  • Did you do a debug build? Commented Feb 1, 2018 at 14:19
  • @JoePhillips: the DLL is in a debug folder, at least Commented Feb 1, 2018 at 14:21
  • 1
    @ThomasWeller Yes but it could have been built before any tests existed. There's really not much else that could go wrong here Commented Feb 1, 2018 at 14:23
  • Yes, I did a debug build. Also I tried a release build and updated the path. I am aware of the difference between the 2 build solutions :) Commented Feb 1, 2018 at 14:27
  • 1
    Updating to use vstest.console actually works and runs all the tests. This can be moved to an answer for me @Caramiriel Commented Feb 1, 2018 at 14:45

2 Answers 2

2

If you want to use mstest.exe, you need following reference in your project file:

<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> 

If you have instead (which seems to be the default for newly created test projects):

<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> </Reference> <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> </Reference> 

you need to use vstest.console.exe

Please note that VSTest.Console.exe is optimized for performance and is used in place of MSTest.exe in Visual Studio 2012.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot for the solution! It really helped a lot!
1

I ran into the same problem and it took me some time to figure out. The actual solution is in the comments.

My Tests are getting discorvered using vstest.console.exe:

Visual Studio Enterprise 2017:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"

See https://learn.microsoft.com/en-us/visualstudio/test/vstest-console-options for further info.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.