4

I have added a Unit Test App(Universal Windows) Project in Visual Studio 2015. It discovers and runs all test cases in Test Explorer in IDE correctly. But when running MSTest.exe from command line, it gives the message "No tests to execute". Command executed is

MSTest.exe /testcontainer:"F:\Projects\MyUnitTests\bin\Release\MyUnitTests.exe" /resultsfile:F:\testResults.trx

Same result when used 'vstest.console.exe' as suggested here.

Also, most of the examples online provide a dll to mstest. But there is no dll created in outputs in vs2015. Need this to be executed by script in jenkins. Has anyone else faced this issue?

Community
  • 1
  • 1
Raunak Yadav
  • 119
  • 1
  • 1
  • 7

1 Answers1

0

When you run against the exe, you should get a warning similar to this that gives you some hints:

Warning: Unit tests for Windows Store and Windows Phone apps cannot be run outside appcontainer. Create an app package and run tests in appcontainer mode. http://go.microsoft.com/fwlink/?LinkId=254169

In order to use the universal test project, you need to create an app bundle and then run the tests against that. To create the bundle, right click on your project and select Store=>Create App Packages.

You will create a local app package, so you can select No for the prompt to upload to the windows store.

Next you will be prompted to fill out the output location, version, ...

On this screen, make sure you select Never for the Generate app bundle option.

After clicking create, open the command line to the location where the app bundles were created. You will also have to install the certificate. You can do this from the command line using certutil:

certutil -addstore "Root" .\UnitTestProjectName_1.0.0.0_x86_Debug.cer

Finally, now you can run your tests using the vstest.console.exe command line against the app package:

vstest.console.exe .\UnitTestProjectName_1.0.0.0_x86_Debug.appx /InIsolation

This blog post from Microsoft has more information and some other troubleshooting tips. Even though the blog post is marked for the beta of VS11, it seems that most of it still applies.

John Koerner
  • 37,428
  • 8
  • 84
  • 134
  • Thanks @john-koerner. It works via cmd. A few doubts. 1. So now, there is no way to use a dll as a testSource for vstest.console.exe (as indicated by most docs/blogs) 2. If I run vstest.console.exe via jenkins , i get an error *"Could not start test run for unit tests for Windows Store app:Unit tests for Windows Store apps cannot be run from a service or non interactive process. Please run unit tests from an interactive process."*. 3. Is there any other test project template that creates a dll (maybe in VS Enterprise). I am using VS Community version. – Raunak Yadav Mar 23 '16 at 08:06
  • If you just want a unit test DLL, there are other project templates that create the DLL. If you specifically need the universal, then you will need to use this approach. As for it not running in Jenkins, since this unit test type creates UI, you need to run it as an interactive user. – John Koerner Mar 23 '16 at 11:07