locked
Activating a JS Metro App programmatically and unit tests

    Question

  • Hi everybody,

    I am developing a JS Metro App and I am writing unit tests for its OO architecture, not UI tests. Although testing is fine during development (because I run the tests by myself) I would like to integrate the tests in a CI build. Currently I cannot 'activate' or run a Metro style app with code in any way. I tried various approaches by using the wwahost.exe, the simulator and custom-built tools found on the Web without any success. The worst thing is that there is not even a bit of information on the site about whether this is possible at all.

    Ideally an MSBuild task should be able to package, deploy an App and run it in the Metro context, gather the results from the tests and remove the App.

    So I am asking: Have you tried activating an App programmatically? Is it possible at all? Is there any piece of documentation somewhere that hints about this process? To MS: Is activating Apps programmatically something we could expect or it would not be possible in the future?

    Regards,
    Simicha

    Thursday, April 12, 2012 10:12 AM

Answers

  • Hi Jack,

    First, thanks for moving my post - it seems here is the proper place for it - and sorry for the misplacement.

    Second, I am using the VS11 Beta and thanks for the links. I am trying to do something different though. The tools you linked to are useful for running JS unit tests in a non-Metro application. What I need is just the opposite - my JS tests are dependent on the WinJS API and it doesn't make sense to run them outside that context (not to mention that they will not even work outside).

    So far here's what I found in regards to packaging, deploying and running Metro style Apps programmatically:

    • There are three ways to package an App: Packaging your app using Visual StudioApp packager (MakeAppx.exe)How to create a package (packaging API). The first two are fine as long as you do not try to integrate them into the build process :) (especially the second one) and I haven't tried the third.
    • Deploying Metro style Apps is worse - either through the Store or Visual Studio.
    • Running Apps is actually 'activating' and there are three ways to do that: VS, tapping on an App on the Metro screen and by using file or protocol activation.

    So essentially you can use VS to package and deploy your app (devenv [path_to_sln] /deploy) and then activate it by invoking a protocol (e.g. myprotocol://). The test results are exported from the Metro App via a file written in the Documents library and read by the build process. The bad thing is that this whole process is one big hack and I am curious to know whether MS would have anything different for vNext of VS/W8 that will ease the three operations.

    @JSAndrew I do not know if the above will help you, still I found this article on the Metro MSDN that says VS supports unit testing Metro style Apps with for VC++, VC# and VB. Perhaps that approach will be applicable to your case.

    I hope this helps someone.

    Regards,
    Simicha

    Monday, April 23, 2012 3:50 PM

All replies

  • Hi Simicha,

    Thank you for posting in the MSDN forum.

    Would you mind sharing us detailed information? Whether you are using the VS2011 Beta?

    If you are using it, it seems that we need to use the plugin when we want to create a unit test for the Javescript app, see http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/02/visual-studio-11-beta-unit-testing-plugins-list.aspx.

    In addition, I find an article about Integrating JavaScript Unit Tests with Visual Studio, if possible, please reference it:

    http://stephenwalther.com/blog/archive/2010/12/20/integrating-javascript-unit-tests-with-visual-studio.aspx. Hope it could help.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 17, 2012 2:33 AM
  • I'm in the same position.

    > Ideally an MSBuild task should be able to package, deploy an App and run it in the Metro context, gather the results from the tests and remove the App.

    Exactly. I have this exact scenario at hand, except my tests are straight C++. Still, I need a way to run the app headlessly and gather the results.
    Wednesday, April 18, 2012 9:37 PM
  • Hi JSAndrew,

    Thank you for posting in the MSDN forum.

    I find a thread “Automating C++ unit test runs for Windows Metro” posted by you, whether it is the same issue? It seems that you have resolved it. Am I right?

    If there's any concern, please feel free to let us know.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, April 19, 2012 2:27 AM
  • Hi Simicha,

    I am writing to check the status of the issue on your side. 

    What about this problem now?

    Would you mind letting us know the result of the suggestion?

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 23, 2012 3:17 AM
  • Hi Jack,

    First, thanks for moving my post - it seems here is the proper place for it - and sorry for the misplacement.

    Second, I am using the VS11 Beta and thanks for the links. I am trying to do something different though. The tools you linked to are useful for running JS unit tests in a non-Metro application. What I need is just the opposite - my JS tests are dependent on the WinJS API and it doesn't make sense to run them outside that context (not to mention that they will not even work outside).

    So far here's what I found in regards to packaging, deploying and running Metro style Apps programmatically:

    • There are three ways to package an App: Packaging your app using Visual StudioApp packager (MakeAppx.exe)How to create a package (packaging API). The first two are fine as long as you do not try to integrate them into the build process :) (especially the second one) and I haven't tried the third.
    • Deploying Metro style Apps is worse - either through the Store or Visual Studio.
    • Running Apps is actually 'activating' and there are three ways to do that: VS, tapping on an App on the Metro screen and by using file or protocol activation.

    So essentially you can use VS to package and deploy your app (devenv [path_to_sln] /deploy) and then activate it by invoking a protocol (e.g. myprotocol://). The test results are exported from the Metro App via a file written in the Documents library and read by the build process. The bad thing is that this whole process is one big hack and I am curious to know whether MS would have anything different for vNext of VS/W8 that will ease the three operations.

    @JSAndrew I do not know if the above will help you, still I found this article on the Metro MSDN that says VS supports unit testing Metro style Apps with for VC++, VC# and VB. Perhaps that approach will be applicable to your case.

    I hope this helps someone.

    Regards,
    Simicha

    Monday, April 23, 2012 3:50 PM
  • I ended up getting around this issue by instead utilizing the built in Visual Studio Test Runner to execute my tests. So yes, this issue is resolved. Thanks.
    Wednesday, April 25, 2012 6:31 PM