Running Universal Windows unit tests from the command line

前端 未结 4 2216
北恋
北恋 2020-12-02 21:37

How do you run Universal Windows (UWP) unit test projects from the command line?

I am using the MSTestFramework.

4条回答
  •  半阙折子戏
    2020-12-02 22:01

    I followed Ivan Marinov's answer, but I needed a purely command-line solution. Once you have your UWP Unit Test Project working and you are ready to automate, follow these steps :

    (I named my solution Win10Universal and my unit test project Win10-UnitTests. You will need to substitute the names in my examples with your own)

    1. Open Command Prompt as an administrator and navigate into the same directory as your solution.

    2. Run MSBuild.exe on your solution.

    >"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" Win10Universal.sln /p:Platform=x86;Configuration=Release

    1. The build process will generate a directory similar to {SolutionDirectory}/AppPackages/{UnitTestTargetProjectName}/{Something_Test}. Navigate into this directory and inside you will see a .cer Security Certificate.

    >cd AppPackages/Win10-UnitTests/Win10-UnitTests_1.1.0.0._x86_Test

    1. Run CertMgr.exe on this generated certificate. This step will fail if you are not running Command Prompt with administrator privileges.

    >"C:\Program Files (x86)\Windows Kits\10\bin\x86\certmgr.exe" -add Win10-UnitTests_1.1.0.0_x86_Release.cer -s -r localmachine root

    1. Run VSTest.Console.exe on the .appx file in this directory.

    >"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" Win10-UnitTests_1.1.0.0_x86_Release.appx /Platform:x86

    You should see your unit tests listed out in the window if you've done everything right! Hope this helps!

提交回复
热议问题