locked
accessing resw causes mstest command error

    Question

  • I have a problem with running mstest in command prompt.

    I have a class library(A.dll) that access the resw file.
    And I also have a test project(produces TestA.dll) to test the A.dll.

    I can run the test within unit test explorer successfully.
    Howerver, when I run that test in command prompt, test fails and error message says "The process has no package identity."
    I found that accessing resw file cause the problem. When I remove the code that access to the resw, test runs fine.

    The command I typed in the Developer Command Prompt is:
    mstest /testcontainer:"C:\[path to the TestA.dll project]\bin\Release\TestA.dll" /detail:errormessage

    How I access to the resw file in A.dll is:
    ResourceManager.Current.MainResourceMap.GetSubtree("A/Resources").GetValue("String1").ToString();


    Does anybody know how to get around this ?

    Monday, April 23, 2012 10:34 AM

Answers

  • Thanks for the patience Hamling-ling,

    ok, so the product group tells me that we should be using vstest.console.exe to test from the command prompt.  Here is the procedure to run unittests from the command line: (thanks Aseem Bansal for the information!)

    1. Ensure that you are able to run tests present in your metro style unittest library project via UTE.
    2. Create an appx from the project. (Right click –> Store –> Create appx –> Local appx..)
    3. Once appx is created, open the directory which contains the appx.
      From a developer command prompt change to the directory where the appx file was created
    4. Find out the path to the certificate file. (In the directory (or one of the child directory) where appx is created, there will be a certificate file.)
    5. Add the certificate to the cert store using the below command.
      Certutil –addstore root <path to certificate file>
      Example: -
      certutil -addstore root c:\projects\ClassLibrary1\UnitTestProject1\AppPackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test/UnitTestProject1_1.0.0.0_AnyCPU_Debug.cer
    6. Find out the path to the appx file (It will be present along with the certificate file)
    7. Now run the tests using vstest.console specifying the path to appx file.
      vstest.console " c:\projects\ClassLibrary1\UnitTestProject1\AppPackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test\UnitTestProject1_1.0.0.0_AnyCPU_Debug.appx"

    You can omit full paths to vstest.console and certutil if the apppackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test is your current directory in the command prompt.

    If you are automating this via Team Build, then this blog will be useful:

    http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/03/08/running-win8-metro-style-tests-in-teambuild.aspx

    much appreciated,

    mike

    • Marked as answer by hamling-ling Friday, April 27, 2012 4:23 AM
    Thursday, April 26, 2012 4:59 PM
    Moderator

All replies

  • Hello,

    this looks like a bug.  It looks like it never even tries to run it from the appcontainer vstest.executionengine.appcontainer.x86.exe.  I need to dig deeper into this.  I have also reported the issue with the product group.

    thanks for the patience,

    mike

    Wednesday, April 25, 2012 1:56 AM
    Moderator
  • Hi Mike

    Thank you for your reply.

    Okey. I'll temporarily comment out the test code untill the solution comes up.

    Thursday, April 26, 2012 1:28 AM
  • Thanks for the patience Hamling-ling,

    ok, so the product group tells me that we should be using vstest.console.exe to test from the command prompt.  Here is the procedure to run unittests from the command line: (thanks Aseem Bansal for the information!)

    1. Ensure that you are able to run tests present in your metro style unittest library project via UTE.
    2. Create an appx from the project. (Right click –> Store –> Create appx –> Local appx..)
    3. Once appx is created, open the directory which contains the appx.
      From a developer command prompt change to the directory where the appx file was created
    4. Find out the path to the certificate file. (In the directory (or one of the child directory) where appx is created, there will be a certificate file.)
    5. Add the certificate to the cert store using the below command.
      Certutil –addstore root <path to certificate file>
      Example: -
      certutil -addstore root c:\projects\ClassLibrary1\UnitTestProject1\AppPackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test/UnitTestProject1_1.0.0.0_AnyCPU_Debug.cer
    6. Find out the path to the appx file (It will be present along with the certificate file)
    7. Now run the tests using vstest.console specifying the path to appx file.
      vstest.console " c:\projects\ClassLibrary1\UnitTestProject1\AppPackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test\UnitTestProject1_1.0.0.0_AnyCPU_Debug.appx"

    You can omit full paths to vstest.console and certutil if the apppackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test is your current directory in the command prompt.

    If you are automating this via Team Build, then this blog will be useful:

    http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/03/08/running-win8-metro-style-tests-in-teambuild.aspx

    much appreciated,

    mike

    • Marked as answer by hamling-ling Friday, April 27, 2012 4:23 AM
    Thursday, April 26, 2012 4:59 PM
    Moderator
  • Hi Mike.

    Thank you for the instruction and solution. It all worked fine.

    One little thing to mention is that I use MSBuild and it creates appx so that I dodn't have to "Right click -> Store ..." everytime and everything can be done in the command line. In the GUI build on the other hand, appx won't created unless manually create it. But it won't be a problem because in the GUI, we better to use test explorer.

    Friday, April 27, 2012 4:55 AM
  • Hi Mike,

    This works, but when we do vstest.console c:\projects\ClassLibrary1\UnitTestProject1 \AppPackages\UnitTestProject1_1.0.0.0_AnyCPU_Debug_Test\UnitTestProject1_1.0.0.0_AnyCPU_Debug.appx  /Enablecodecoverage

    It says, Code coverage is not available for Windows Store apps. Code coverage analysis skipped for this test run.

    Can we have some solution to take code coverage for this?

    Thursday, December 6, 2012 5:25 PM