Answered Error while running unit test

  • Thursday, April 12, 2012 6:12 PM
     
     
    I followed the instructions here to create a unit test in the same project for a WinRT dll.

    http://msdn.microsoft.com/en-us/library/hh419385%28v=vs.110%29.aspx#sameProject

    Basically modified the include and the library paths and create a C++ unit test class in the same project. When i run the unit test, it says

    ------ Run test started ------
    An internal error occurred while launching test executor for Windows Metro style app.

All Replies

  • Monday, April 16, 2012 6:23 AM
    Moderator
     
     

    Hello amshinde,

    I am sorry that I can't reproduce your issue, I can run my C++ unit tests successfully on my side. As far as I know that WinRTComponentDll project is one kind project of Metro Style projects, so I think when you create test project you need to create new unit test project under the Metro Style category. File->New->Project->Visual C++->Windows Metro style->Unit Test Library.

    If you still get the same error message, please offer me the detailed steps you tried on your machine.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, April 16, 2012 4:41 PM
     
     

    I am adding the unit  tests in the same project as the product code, so that I can test the private functions. If I add the tests in a different project, then i can access only the public functions of the WinRT class exposed.

    I have always been getting the error. Is there some way to see the log messages?
  • Tuesday, April 17, 2012 7:56 AM
    Moderator
     
     

    Hello amshinde,

    In order to help you with your issue I need to first reproduce it on my side. Could you please share me one simple project which can reproduce it? I would like to take a deep look at it. You can send it to via eamil: v-vison @ Microsoft dot com.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

  • Sunday, April 22, 2012 1:43 AM
     
     

    Hello, I have exactly the same problem, I already sent an email to you with a zipped project that reproduce this issue.

    Take into account that the problem is when I try to test internal, classes inside a C++ WinRT component.

    Following the steps given in this document: http://msdn.microsoft.com/en-us/library/hh419385%28v=vs.110%29.aspx

    Section: To add unit tests in the same project

    I really need a solution about this problem. 

    Thank you!


    Marcelo

  • Thursday, April 26, 2012 9:38 AM
     
     

    Hi amshinde,

    I tested your code and I found that the WinRTComponentDll is not the unit test DLL. There are no CppUnitTestFramework and TestPlatform references in this project.

    You can check it in this way: Right Click the test dll->References

    When I add a unit test project, it works fine for testing the Application1. I suggest you to create a unit test project as Vicky said.

    For the Private function accessors, this feature is removed from VS11

    Private Accessors – This feature was deprecated in the VS2010 product and has been removed in VS11. If you have test projects from VS2010 that include private accessors, they will still work in VS11, but the wizard for creating new ones no longer exists.

    You can check Removed or deprecated in VS11 section in this document.
    http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/08/what-s-new-in-visual-studio-11-beta-unit-testing.aspx

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, April 26, 2012 12:41 PM
     
     Answered

    Hi amshinde / Marcelo,

    The steps described in http://msdn.microsoft.com/en-us/library/hh419385%28v=vs.110%29.aspx#sameProject are valid only for Unit Tests for desktop applications.

    You need to use project template "Visual C++" -> "Windows Metro style" -> "Unit Test Library" for writing unit tests for WinRT Component library. Tests in WinRT Component DLL are not offically supported for Metro style apps.

    Generally a typical user will test against public APIs and above method will suffice for them. For accessing non public code directly, if you still want to try non supported/non recommended way of running test from WinRT Component Library you can try steps in following post that will make your WinRT component to a unit test library project also.
    http://blogs.msdn.com/b/vikramagrawal/archive/2012/04/26/how-to-write-tests-in-winrt-component-dll-project-for-vs11-beta-consumer-preview.aspx

    Thanks.


    Regards, Vikram Agrawal, Developer, VSTLM, Microsoft Corporation

    • Proposed As Answer by _EnderW Thursday, April 26, 2012 1:44 PM
    • Marked As Answer by Vicky SongModerator Thursday, May 03, 2012 5:40 AM
    •  
  • Thursday, April 26, 2012 1:08 PM
     
     Answered

    Thanks for this information.

    I did a work around creating the UnitTest inside the project, and also creating an Unit Test project outside that forwards each test to the real unit test in the library... it is working very straight forward :)

    It would be great if MS add support for unit test in the same project. It is sometimes useful testing internal clases, because sometimes we have legacy code and refactor it to make it testeable could be a hard work.

    Regards

    Marcelo


    Marcelo

  • Thursday, April 26, 2012 1:09 PM
     
     

    Thanks for this information. 

    As I mention i found a work around, I am preparing an article about it and i will post it here in order to get feedback.

    Thanks a lot!



    Marcelo

  • Thursday, April 26, 2012 3:04 PM
     
     Answered