microsoft / testfx

MSTest framework and adapter
MIT License
716 stars 253 forks source link

Filter by /category with mstest.exe and VS2017 via Commandline #272

Closed deBloB90 closed 6 years ago

deBloB90 commented 6 years ago

Description

"No tests to execute" if the "/category" filter is used with mstest.exe via commandline and an VS2017 created unit test container. The same procedure works fine for an VS2015 created unit test container.

Steps to reproduce

I have created a simple unit test project in VS2017 with two unit tests. These tests are marked with the category "Ores" as shwon below:

[TestClass] public class Copper { [TestCategory("Ores"), TestMethod] public void CheckCopper() { DataMiner locMiner = new DataMiner(); string result = locMiner.GetCopper(); Assert.AreEqual("Copper", result); } }

Expected behavior

Execute all unit tests of category "Ores"

Actual behavior

"No tests to execute"

Environment

Visual Studio 2017 package id="MSTest.TestAdapter" version="1.2.0-beta3" targetFramework="net452" package id="MSTest.TestFramework" version="1.2.0-beta3" targetFramework="net452" MSTest.exe is linked through the Path variable: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE;"

Examples

mstestlauft mstestlauftnicht

AbhitejJohn commented 6 years ago

@deBloB90: The VS 2017 test containers default to using the MSTestV2 Framework which is primarily supported using the vstest.console.exe runner. Can you move over to running your tests via vstest.console.exe instead? This is the recommended runner for unit testing scenarios.

deBloB90 commented 6 years ago

Thanks for the reply, John. I am struggling with vstest.console.exe and VS2017 created unit test assembly. The vstest.console.exe refuses to find my unit tests.. Same behaviour here as for mstest.exe: All fine with an VS2015 generated unit test lib.

I have searched a lot but cant find the up to date documentation for command line based unit testing with VS2017. The msdn articles describe the handling with VS2012/13. https://msdn.microsoft.com/de-de/library/jj155796.aspx https://msdn.microsoft.com/en-us/library/ms182490.aspx Can you give me a hint for the actual documentation? Thanks!

Both assemblys are .Net 4.6 and AnyCPU (x86 as standard test architecture) Both times the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\VSTest.console.exe" is used.

Execution of an VS2017 generated unit test assembly: vstest17 console nope (Sorry for german output, translated: In "testassembly" is no executable unit test. Ensure that testdiscover- and executor are registered and the settings for platform and version are accurate.)

Execution of an VS2015 generated unit test assembly, all fine!: vstest15 console ok

deBloB90 commented 6 years ago

I solved the problem with vstest.console.exe.

In the first shot, i used the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" which is version 15.0.0.0

Finally i tried "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" which is version 15.0.26720.2

Now the test execution and the filter works. vstest17 console ok finaly

Maybe I didn't dig deep enough, otherwise it would be a blessing if this information were included in the documentation.

AbhitejJohn commented 6 years ago

@deBloB90: Glad you were able to resolve this. This documentation might help: https://msdn.microsoft.com/en-us/library/jj155796.aspx. The new version of vstest.console which is cross-platform has all of its documentation here: https://github.com/microsoft/vstest-docs .

I'm closing this issue, assuming you are un-blocked. Do let us know otherwise.