-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Improve the debugging experience of tests #14755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dotnet] Improve the debugging experience of tests #14755
Conversation
Use the new `ConfigureAwait(ConfigureAwaitOptions)` method introduced in .NET 8 to avoid first-change exceptions in the test cleanup
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So smart for test project. I vote for keeping simplicity, rather than being technically perfect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized we don't actually need to dispose the HTTP response, since we are disposing the client. I made it a little simpler, do you think this is acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a lot of try/catch in codebase, how this one affects your debugging experience?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I have something mis-configured, but the webserver Stop method always throws an exception for me, as shown in the PR description. This is something which causes a debugger break every time I am running tests.
It would be nice to avoid the debugger breaking on other exceptions which are well-handled, such as Runfiles.Create(). However, those are in synchronous methods, and there is no nice way to get that to happen.
Luckily, the quit method is an asynchronous operation and .NET 8 has an await modifier which avoids throwing the exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this is a simplification. It requires extracting a method only because Stop is currently synchronous. Would it be better to make Stop async, and propagate that out to the callers? It would not be more complex, and it would avoid doing sync-over-async where it is not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It throws on my end, but my debugger doesn't hit it. If making Stop() method asynchronous will help you, then it is better. Thanks.
|
Sorry, I cannot accept it. We have a lot of Again sorry, and thanks for understanding. |
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Use the new
ConfigureAwait(ConfigureAwaitOptions)method introduced in .NET 8 to avoid first-chance exceptions in the test cleanupMotivation and Context
When debugging through code, .NET provides first-chance exceptions, allowing users to see exceptions as they are thrown, even if they are handled or suppressed.
Unrelated exceptions can get in the way when testing unrelated code. This change makes the debugger break less when it is not necessary.
Types of changes
Checklist
PR Type
enhancement
Description
QuitNoThrowmethod to handle HTTP requests in a way that suppresses exceptions during test cleanup.QuitNoThrowmethod in theStopmethod ofTestWebServer.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing)to prevent first-chance exceptions from interrupting the debugging process.Changes walkthrough 📝
TestWebServer.cs
Improve test cleanup by suppressing exceptions using ConfigureAwaitdotnet/test/common/Environment/TestWebServer.cs
QuitNoThrowmethod to handle HTTP requests without throwingexceptions.
QuitNoThrowin theStopmethod.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing)tosuppress exceptions.