Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

mstest - Running Universal Windows unit tests from the command line

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

I am using the MSTestFramework.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Short answer:

vstest.console.exe /Platform:x64 AppPackagesUnitTestProject1_1.0.0.0_x64_Debug_TestUnitTestProject1_1.0.0.0_x64_Debug.appx

Long answer:

  1. Create the project by selecting Universal / Unit Test App (Universal Windows) template:

    enter image description here

  2. Build it with command line using in the folder where the solution file is

    msbuild /p:Platform=x64;Configuration=Debug

  3. Try running the vstest.console.exe command above, in the short answer. It will fail, giving the following error message:

    error 0x800B0109: The root certificate of the signature in the app package or bundle must be trusted..
    For more details look into Event Viewer under Applications and Services Logs -> Microsoft -> Windows -> AppXDeployment-Server -> Microsoft-Windows-AppXDeploymentServer/Operational.
    
  4. To be able to run tests from command line, you need to use a certificate which has trusted root, or make the certificate that generated by visual studio trusted. For the latter, double click UnitTestProject1_TemporaryKey.pfx file from windows explorer, and follow the import wizard default steps, but change two things:

    • Set Store Location to local machine: enter image description here
    • Place the certificate to Trusted Root Certification Authorities store: enter image description here
    • Finishing the wizard should say "The import was successful."
  5. Try running vstest.console.exe using the parameters in the short answer, and now it should run all your tests.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...