Skip to content

Conversation

@DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented Jun 8, 2023

This change sets DefaultTraceListener.AssertUiEnabled to false during test runs to avoid displaying assert dialogs, which can hang CI machines. To ensure that we continue seeing assertions fail during debug tests (just without UI) a new ThrowingTraceListener has been added.

@DustinCampbell DustinCampbell requested a review from a team as a code owner June 8, 2023 17:44
}
}

public override void Fail(string? message, string? detailMessage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, a single test will fail with this exception now instead of hanging the machine right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DefaultTraceListener is responsible for displaying the assert dialog UI when a Debug.Assert or Debug.Fail triggers a failure. This would change such failures to throw an exception. That might fail the test, but only if the exception isn't caught before xUnit sees it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'll do this a bit differently. The DefaultTraceListener has some useful behavior too, since it controls Debug.Write(...) as well. I'm thinking that I'll leave it in place but disable the assertion UI.

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that this will still throw an exception and possibly fail a test. From the convo on teams I was worried it would just gloss over the asserts, but I would much rather know about them and validate.

@DustinCampbell
Copy link
Member Author

I'm going to go ahead and merge this to help others PRs make progress in CI.

@DustinCampbell DustinCampbell merged commit 7ab72a9 into dotnet:main Jun 8, 2023
@DustinCampbell DustinCampbell deleted the assert-dialogs branch June 8, 2023 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants