locked
Can no longer run unit tests with Universal Apps RRS feed

  • Question

  • Over the past few months I was writing a Universal App using the RC of Visual Studio.  Everything worked fine including the execution of the unit tests.  With the final release of Visual Studio, I adjusted to the project (well, created a new one) and moved my code over.  All is back to where it should be except my unit tests fail to work. 

    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](http://go.microsoft.com/fwlink/?LinkId=254169)

    No test is available in the provided sources. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

    Thinking the problem was with my code, I created a new blank project, added a unit test project and got the same results.

    I don't want to use TFS to run my unit tests, I should be able to run them directly from Visual Studio.  Anyone have any idea what I'm missing?

    Monday, August 3, 2015 5:28 PM

Answers

  • Hi Jack,

    So I uninstalled VS 2015 (I also had the community edition installed) and reinstalled using the same link as provided.

    I created a new project using the same steps as before.  This is running without a reference to the app.  Notice it stated it ran, but not in Test Explorer.  I can't seem to reproduce the error about running in an app container with this test app (still existing in my main app):

    • Marked as answer by A.Coles Sunday, August 9, 2015 11:59 AM
    Thursday, August 6, 2015 11:30 PM

All replies

  • Hi A.Coles,

    Do you mean that you use the VS2015 RC before? You use the VS2015 RTM now, am I right? If so, do you install the RTM in the same machine?

    How did you run your test, in VS IDE or command line?

    >>Thinking the problem was with my code, I created a new blank project, added a unit test project and got the same results.

    Could you share us a screen shot about the unit test project template in your VS? Which one unit test project did you create, windows 10 univeral unit test project or others?

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 5, 2015 9:24 AM
  • I also have the same problem when trying to run the unit tests. I created a new Universal Windows Unit Test App project just like A.Coles and tried running the supplied sample test method and got the same 'app cannot be run outside appcontainer' message.

    The weird thing is that the error only occurs for me on my laptop but it works fine on my desktop which led me to think maybe this is hardware related. Both my desktop and laptop run windows 10 and have the same version of visual studio installed. The only significant different in hardware is my desktop runs intel and laptop runs amd.

    Wednesday, August 5, 2015 4:41 PM
  • Hi Jack,

    Sorry, let me clarify.  I was using RTM which worked fine.  Today I'm using VS Enterprise 2015.  The RTM is no longer on my machine.  Like Jingyu below, I'm also running on a notebook.

    All tests are run directly through the IDE

    Here's the instructions to recreate the problem yourself:

    Create Project called App1
    1. Blank App (Universal Windows)
    2. Create class (FooBar)
    3. Add public bool TestMe() { return false} in FooBar

    Add unit test to solution
    4. Unit Test App (Universal Windows)
    5. Add reference to App1
    6. In TestMethod1() in UnitTest.cs add
                var foo = new Foobar();
                Assert.IsTrue(foo.TestMe());

    7. From Test Explorer turn TestMethod1

    The output will show:

    ------ Discover test started ------
    ========== Discover test finished: 1 found (0:00:00.2760031) ==========
    ------ Run test started ------
    ========== Run test finished: 0 run (0:00:00.4530022) ==========

    Yet inside the Test Explorer window will show the test as not run.

    8. Next, Run App1 and close it. 
    9. Now run the unit test, you'll get the following message:

    ------ Run test started ------
    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](http://go.microsoft.com/fwlink/?LinkId=254169)
    No test is available in the provided sources. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
    ========== Run test finished: 0 run (0:00:05.7882814) ==========

    Here's the image you were asking for:

    Wednesday, August 5, 2015 9:59 PM
  • Hi A.Coles,

    >>I was using RTM which worked fine.  Today I'm using VS Enterprise 2015.  The RTM is no longer on my machine. 

    Actually the VS Enterprise 2015 RTM is the latest version. The previous version is RC version, the new version is RTM version. So VS Enterprise 2015 is the RTM version. You could download it here:

    https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx

    I test it in my Windows 10 machine, I just change the code "public bool TestMe() { return true}".

    We use the latest Windows 10 RTM and VS2015 Enterprise RTM version. Just to make this issue clearly, do you use the latest windows 10 Environment/VS2015? As far as I know, if we run the unit project in windows 10 Preview version, it would have severl issues.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 6, 2015 6:40 AM
  • Hi Jack,

    So I uninstalled VS 2015 (I also had the community edition installed) and reinstalled using the same link as provided.

    I created a new project using the same steps as before.  This is running without a reference to the app.  Notice it stated it ran, but not in Test Explorer.  I can't seem to reproduce the error about running in an app container with this test app (still existing in my main app):

    • Marked as answer by A.Coles Sunday, August 9, 2015 11:59 AM
    Thursday, August 6, 2015 11:30 PM