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?
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.