none
[UWP] Unit tests stuck RRS feed

  • Question

  • Hi,

    I'm trying to run a unit test on my UWP app:

    - I created a Unit Test project and referenced my UWP app.

    - I created a simple unit test (at this moment it's just Assert.Equals(true,true) )

    - I started the test (Run, Run All, or Run Selected Tests)

    - VS displayed a default UI briefly and then closed it.

    - The animated progress bar run indefinitely. It looked like VS was stuck.

    - I tried to cancel the unit test. VS kept displaying the progress bar. It seems it was stuck on cancelling either.

    - I had to close and re-open VS to stop the test.

    I'm using VS 2015 Community edition.

    Has anyone experienced this kind of behaviour? How can I run unit tests on UWP apps?

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Tuesday, February 28, 2017 5:57 PM

All replies

  • Hi Leszek,

    My coworker did experience this, at that time it was just gone after restarting VS.

    So, I wonder if this issue keeps showing up every time you run UWP unit test.

    To check if this only happen to UWP unit test, you could create another unit test to run, which could help to narrow the issue.

    As I run the test in my side, the output window would show the details of the process. When the unit test is stuck, at moment you could find the specific process, and it’s probably caused by that.

    To get the details as above, you need go to Tools-> options -> projects and solutions -> MSBuild verbosity(I changed them to Detailed)

    BTW, to let the test pass, I use

    Assert.AreEqual(true, true);

    Instead of

     Assert.Equals(true,true);

    Because the latter would fail.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 1, 2017 9:04 AM
  • Thanks Fletch for your response.

    I enabled detailed information and this is what I get in the Output window during test running:

    Checking whether required frameworks are installed...
    
    Framework: Microsoft.VCLibs.140.00.Debug/x86, app package version 14.0.24210.0 is installed.
    
    Framework: Microsoft.NET.CoreRuntime.1.0/x86, app package version 1.0.23819.0 is installed.
    
    Framework: Microsoft.VCLibs.140.00.Debug/x86, app package version 14.0.24210.0 is installed.
    
    Registering the application to run from layout...
    
    Deployment complete (0:00:04.806). Full package name: "962e431d-e5ba-459a-a065-765582236db5_1.0.0.0_x86__v1hw3xc3cncwt"

    It looks very similar to your output except the line "Run test finished". There is no information about any process that gets stuck but VS

    is stuck anyway. When I press Cancel, nothing changes, no new messages in the Output window and VS is still stuck.

    I have created a brand new solution with another project and a test project (all UWP because this is what I need to test) with the same results: VS gets stuck after pressing Run Tests.

    Any other suggestions?

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Wednesday, March 1, 2017 2:51 PM
  • Hi Leszek, 

    Maybe there is something wrong with your Visual Studio or machine's performance.

    Please refer to the following steps to troubleshot your issue.

    1). Reboot the machine and try again.

    2). You could start VS in safe mode (devenv /SafeMode), which could prevent all third-party VSPackages from loading when Visual Studio starts, thus ensuring stable execution.

    Click Start->Developer Command Prompt for VS-> type “devenv /SafeMode”

    3). If above steps could not work for you, I suggest you need to repair VS

    click start->control panel-> programs and features->right-click Microsoft Visual Studio VS 2015->change-> Repair

    Best regards,

    Fletch



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 2, 2017 9:26 AM
  • Thanks Fletch for your suggestions. I have tried them (including VS repair) with no luck - the unit test just keeps hanging indefinitely. There is a small change though. I started to get an HRESULT error when the unit test starts:

    ------ Run test started ------
    DEP3000 : Attempts to stop the application failed. This may cause the deployment to fail. 
    Exception from HRESULT: 0x92330047
    
    Updating the layout...
    
    Copying files: Total 8 mb to layout...
    
    Checking whether required frameworks are installed...
    
    Registering the application to run from layout...
    
    Deployment complete (0:00:06.53). Full package name: "962e431d-e5ba-459a-a065-765582236db5_1.0.0.0_x86__v1hw3xc3cncwt"

    I have found a few more suggestions on the web (such as re-deploying the app) from people who experienced the same error. Still, no luck. One suggestion was to wait for VS 2017 and this is what I'm going to do. I gave up trying to fix unit testing in VS 2015. It's not worth your and my time.

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Friday, March 3, 2017 3:14 PM
  • Hi Leszek,

    I feel sorry about that, I wish I could repro this in my side and help you out.

    But maybe VS2017 is a better choice and the its RTM version will be released in a few days.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 6, 2017 1:54 AM
  • Thanks Fletch.

    I'm really perplexed. I have just installed Visual Studio 2017 Community Edition and run a plain vanilla Unit Test for UWP with just one line of code:

    Assert.Equals(true, true);

    The behaviour is exactly the same as in VS 2015 (!): VS 2017 gets stuck. The messages in the Output window are similar:

    Checking whether required frameworks are installed...
    
    Framework: Microsoft.NET.CoreRuntime.1.1/x86, app package version 1.1.24920.0 is installed.
    
    Framework: Microsoft.VCLibs.140.00.Debug/x86, app package version 14.0.25017.0 is installed.
    
    Registering the application to run from layout...
    
    Deployment complete (0:00:02.901). Full package name: "852dddf2-1ce7-4091-a0d6-ea4d8711240b_1.0.0.0_x86__v1hw3xc3cncwt"

    ...and CPU sits at 2-5%, disk at 10% mainly from Windows Telemetry Service. My computer is not new but it is quite fast (Intel i7-3770 @ 3.4GHz with 16 GB RAM and 1GB Graphics Card).

    How can I make the UWP unit tests work? Where should I look to diagnose that?

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Wednesday, March 8, 2017 3:44 PM
  • Hi Leszek,

    Sorry about your suffering this.

    Would you mind migrating to a new computer, building a new uwp unit test to see if this issue still exists?

    According to your trying VS2017, and it still happened, then it just made me think it could be related to your system.

    Please check the Win10 version (open “cmd” and type “slmgr/dlv”), mine is 10.0.14393.351.

    Try to update Win10 to the latest version if it’s not.

    After running the UWP unit test, you could also have the application events:

     Start->Right-click This PC->More->Manage->System Tools->Event Viewer->double-click Application

    Then all logs of applications are displayed in list box. Please view whether has logs of Visual Studio.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 10, 2017 6:05 AM
  • Hi Fletch,

    I'm not able to migrate to another computer at this moment but I may try this approach at some point.

    I'm running exactly the same version of Win10 as you (10.0.14393.351). I have also checked Event Viewer but I have not found any entries for Visual Studio.

    There is a change in the Output window though. It displays the following message when my unit test is lauched:

    DEP3000: Attempts to stop the application failed. This may cause the deployment to fail. [0x92330047] Exception from HRESULT: 0x92330047
    

    I googled the error message and I found a few posts that described exactly the same behaviour I was experiencing. Unfortunately, there was no working solution for this problem.

    I have also noticed these warnings. I'm not sure if there are related to the problem:

    Warning: Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. MyUnitTests   
    Warning  Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. MyProject

    Should I try to resolve these conflict? If so, how?

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Friday, March 10, 2017 5:16 PM
  • Hi Leszek,

    I tried to repro this issue on VS 2017 community, test still could pass if use if I use the code:

    Assert.AreEqual(true, true);


    but the test failed on this which you used:

    Assert.Equals(true, true);

    It may be not directly related to the stuck, but you could try using the Assert.AreEqual() method to have a look.

    As for the conflicts, it is the result of setting "Detailed" to MSBuild project build output verbosity level. You could change it to "Diagnostics".

    Best regards,

    Fletch

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 14, 2017 2:38 AM
  • Thanks Fletch.

    I have tried Assert.AreEqual(true,true) with the same result: VS being stuck on the unit test. I have also created a brand new VS solution and project and it shows no conflicts anymore.

    Regarding the error "DEP3000 : Attempts to stop the application failed. This may cause the deployment to fail. Exception from HRESULT: 0x92330047" I've found this interesting answer in StackOverflow:

    The test app launched by visual studio uses the local network to send the unit testing results to the IDE app. If there is more than one network adapter on your computer, the unit testing framework can get confused and try communicating with the IDE via the wrong network adapter. Thus, the VS TestExplorer just hangs there waiting for a response from the test app while the test app hangs there trying to find the TestExplorer over the wrong network.

    The workaround: My development system has three network adapters: Ethernet, Bluetooth and Wi-Fi. Disabling both the unused Bluetooth and Wi-Fi adapters forced the unit testing framework to locate the IDE on the correct adapter. After that, the unit testing started to function again. Once it started working, I was able to re-enable the other two adapters. I assume that if it fails again, then I would have to go through the same process.

    Microsoft will eventually include a fix for this problem in a future build of Visual Studio, but until that time, you can remedy the issue and disabling the unused network adapters, run the unit tests so they can locate the TestExplorer, and then re-enable the adapters.

    Source: http://stackoverflow.com/questions/39459264/unit-testing-in-visual-studio-2015-has-stopped-working

    I followed the advice and disabled my network adapters (Wi-Fi and Bluetooth) and indeed, the error message disappeared although Visual Studio still was stuck on the unit test.

    I must admit that it's very frustrating to not be able to run such a basic tool as unit test. I hope Microsoft will look at that closely and fix it eventually. It looks like I'm not the only one who experiences these problems.

    In the meantime, I'm considering using Process Explorer or some other tool like that to pinpoint a process that prevents Visual Studio from completing the unit test.

    Do you think it is a good idea? What other tools I could use to pinpoint the problem? I really need the unit tests running.

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Wednesday, March 15, 2017 7:41 PM
  • Hi,

    I have installed the latest update for Win10 (Creators Update) and all patches for VS 2017 hoping they would solve the problem. Well, the problem is still not solved but I got a different error message:

    An exception occurred while invoking executor 'executor://mstestadapter/v2': Method 'get_Properties' in type 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation' from assembly 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation.

    I run the test on a plain vanilla test project with a single method:

    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
    namespace UnitTestProject1
    {
        [TestClass]
        public class UnitTest1
        {
            [TestMethod]
            public void TestMethod1()
            {
                Assert.AreEqual(true, true);
            }
        }
    }

    Thanks for any tips.

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Friday, April 7, 2017 9:14 PM
  • Hi Leszek,

    I was getting the almost same error (my "missing" implementation was for WriteLine, not get_Properties) and the issue was with the nuget packages I was using: MSTest.TestFramework was on version 1.1.18, but MSTest.TestAdapter was still on 1.1.14. Upgrading MSTestAdapter package to the same version as TestFramework made the error message go away and the tests to run again.

    Hope it helps,

    Olivier Guinart [MSFT]

    Monday, September 11, 2017 8:41 PM
  • I can confirm that I experience this same issue. I thought it was only my machine, since other machines seemed to run tests fine. But as it turns out, we created a brand new VM in Azure, installed the latest VS 2017 on it, and UWP unit tests just hang indefinitely, with the app window open. No breakpoints get hit when debugging either.

    Version:

    VS 2017 15.6.4

    Microsoft.NETCore.UniversalWindownPlatform 6.0.8

    MSTest.TestAdapter 1.2.0

    MSTest.TestFramework 1.2.0

    This is costing us valuable dev time.

    Ash


    • Edited by A_Narayanan Friday, March 23, 2018 5:42 AM Typo
    Friday, March 23, 2018 5:42 AM