xUnit succeeded without finishing the test - Visual Studio Debugger crashes - Visual Studio Community Version 17.6.0

daniele luppi 0 Reputation points
2023-06-02T14:44:59.2966667+00:00

Hi there,

in a Windows Form the constructor of a form instantiates a class derived from ComboBox.

This class just changes the background overriding OnEnter and OnLeave

if (Enabled) Backcolor = System.Drawing.Color.FromArgb...

and then call the base class.

This code is still running properly but, when I run the test using xUnit, the test succeeds even when should fail. While debugging the test happens that when Visual Studio instantiates the class it stops, still the test passes.

Just FYI before the last update (2 days ago) test was working properly...

I was able to fix the code specifying the base keyword:

if (**base.**Enabled) **base.**Backcolor = System.Drawing.Color.FromArgb...

This fixed the issue but have more complex scenarios affected too....

What's going on here ? Is VS or xUnit ? Any suggestion ?

Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
336 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Anna Xiu-MSFT 27,641 Reputation points Microsoft Vendor
    2023-06-05T07:36:45.83+00:00

    Hi @daniele luppi

    Welcome to Microsoft Q&A! 

    Please update your Visual Studio to the latest version with Visual Studio Installer and try again. 

    If it doesn’t work, please report it in dedicated xUnit forum. Thanks for your understanding! 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. daniele luppi 0 Reputation points
    2023-06-07T03:54:51.49+00:00

    Hi Anna-Xiu

    thx for getting back to me.

    Actually it was the VS update to cause the issue, anyway I moved the application logic into the proper class and built unit tests for that.

    Unfortunately I still can't do integration tests against the UI part, but I created another project and copied and isolated all the involved parts and was able to reproduce the issue, so in the worst case I can provide a git.

    Debugging is crashing when the constructor is instantiating the components in the Initializer ( designer.cs ). Adding the same controls randomly to a new form doesn't cause any issue but if I copy/paste the components from the problematic form into a brand new form it's still happening.

    I will go back to that in-between the other activities and keep you posted.

    0 comments No comments

  3. daniele luppi 0 Reputation points
    2023-06-21T15:12:58.6066667+00:00

    Finally I was able to look back at the code.

    My bad. Had to define a Single Thread Apartment and didn't disable the timeout.

    Got confused as test was still passing before the update.

    0 comments No comments