locked
unit testing for portable class library (universal library) RRS feed

  • Question

  • I am building a universal portable library (a dll for universal apps: windows 8.1 & WP 8.1) and I want to add a unit test project to the solution.

    I have added a Unit Test Library (windows) project to the solution and the tests are discovered in the test explorer and the unit tests work just fine. But i can't test the dll for Windows Phone.

    I have tried a Coded UI Test Project (windows Phone). The test are discovered in test explorer but i can not test async methods. The debugger says Result StackTrace:

    at VeePlayUnitTests.WindowsPhone.CodedUITest1.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

    And if i try the Unit Test App (windows Phone), it does not get discovered by test explorer. I am using VS2013 U4.

    What am i missing? How do I run a unit test for WP for a universal portable lib

    • Moved by Jamles Hez Thursday, February 5, 2015 6:16 AM
    Wednesday, February 4, 2015 9:56 AM

Answers

  • Hi ventura8,

    I think it might be due to the platform target and the Default Processor Architecture. Did you set them? If so, I would recommend you set them the same value. I think you could try the steps as below:

    1. Set your project targets x64;
    2. Go to the Test Menu-> Test Setting-Default Processor Architecture->x64;
    3. If test methods did not show up, build the solution;
    4. If test methods still did not show up, clean the solution.

    If the steps above do not work, you could try the methods in the link below:

    #Test methods are not showing in test explorer vsts 2012
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a63f0b85-cc74-4eaa-820c-f117d081d9b2/test-methods-are-not-showing-in-test-explorer-vsts-2012?forum=vstest

    Best Regards,

    Edward


    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.


    Monday, February 9, 2015 6:47 AM
  • After hours of configuring and playing around with my solution i finally got it working. I don't remember exactly what i did (i remember that the default unit test template is configured wrong). All i can say is that the solution lays in configuring the Configuration Manager correctly for your unit test and the app/lib you are testing. and configure the build properties of the test unit project. What correctly means will depend on what you (and on what device) you are testing. This helped : http://dotnetbyexample.blogspot.ro/2013/06/x86arm-configuration-gotcha-in-windows.html
    Monday, February 23, 2015 3:36 PM

All replies

  • Hi ventura8,

    Move to Unit Testing forum for a better support.

    Thanks for your understanding,

    --James


    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, February 5, 2015 6:17 AM
  • Hi ventura8,

    >> I have added a Unit Test Library (windows) project to the solution and the tests are discovered in the test explorer and the unit tests work just fine. But i can't test the dll for Windows Phone.
    >> The test are discovered in test explorer but I cannot test async methods.
    >>  How do I run a unit test for WP for a universal portable lib

    What the async methods are. Are they the class methods in the dll?

    If so, the link below shows the details of creating testing apps for windows phone.

    Reference:
    https://msdn.microsoft.com/en-us/library/windows/apps/dn168930(v=vs.105).aspx

    >> And if i try the Unit Test App (windows Phone), it does not get discovered by test explorer. I am using VS2013 U4.

    I am wondering how you created you unit test project. After you create the unit test, if you build the solution, could you get the test method in test explorer window?

    Best Regards,

    Edward


    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.


    Friday, February 6, 2015 2:12 AM
  • >> What the async methods are. Are they the class methods in the dll?

    yes, i am testing async methods from the dll

    >> If so, the link below shows the details of creating testing apps for windows phone.

    I have followed the guide. The test methods don't show up in test explorer

    >> I am wondering how you created you unit test project. After you create the unit test, if you build the solution, could you get the test method in test explorer window?

    I have created the unit test using the template from visual studio 2013. none of the test are discovered by test explorer.

    Friday, February 6, 2015 11:53 AM
  • Hi ventura8,

    I think it might be due to the platform target and the Default Processor Architecture. Did you set them? If so, I would recommend you set them the same value. I think you could try the steps as below:

    1. Set your project targets x64;
    2. Go to the Test Menu-> Test Setting-Default Processor Architecture->x64;
    3. If test methods did not show up, build the solution;
    4. If test methods still did not show up, clean the solution.

    If the steps above do not work, you could try the methods in the link below:

    #Test methods are not showing in test explorer vsts 2012
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a63f0b85-cc74-4eaa-820c-f117d081d9b2/test-methods-are-not-showing-in-test-explorer-vsts-2012?forum=vstest

    Best Regards,

    Edward


    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.


    Monday, February 9, 2015 6:47 AM
  • After hours of configuring and playing around with my solution i finally got it working. I don't remember exactly what i did (i remember that the default unit test template is configured wrong). All i can say is that the solution lays in configuring the Configuration Manager correctly for your unit test and the app/lib you are testing. and configure the build properties of the test unit project. What correctly means will depend on what you (and on what device) you are testing. This helped : http://dotnetbyexample.blogspot.ro/2013/06/x86arm-configuration-gotcha-in-windows.html
    Monday, February 23, 2015 3:36 PM