CSHARP-5930: Stop throwing in test discovery when running locally#1917
CSHARP-5930: Stop throwing in test discovery when running locally#1917ajcvickers wants to merge 1 commit intomongodb:mainfrom
Conversation
| var baseSummary = await base.RunTestCollectionsAsync(messageBus, cancellationTokenSource); | ||
|
|
||
| if (_unobservedExceptionTrackingTestCase == null) | ||
| if (_unobservedExceptionTrackingTestCase.Any()) |
There was a problem hiding this comment.
It's possible/probable that the intention is only to run one of these tests at a time, in which case we need to figure out how to prevent both from being returned by default when running locally.
There was a problem hiding this comment.
You are right, the idea was that on CI we run either tests without category assigned (aka unit-tests) or we run integration tests only (by category), but we want to track for unobserved exceptions in both cases. I was trying to generate that test dynamically, but did not found a nice way to do that, so instead I've simply created 2 tests, but forget to improve runner to support a case when there are 2 of them.
There was a problem hiding this comment.
Pull request overview
Updates the custom xUnit assembly runner used by the test helpers to avoid SingleOrDefault throwing during test discovery when multiple tests are tagged with the UnobservedExceptionTracking category.
Changes:
- Collects all
UnobservedExceptionTrackingtest cases (instead of requiring a single one). - Runs the collected unobserved-exception test cases after the main test run and aggregates their
RunSummary.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
...goDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs
Outdated
Show resolved
Hide resolved
...goDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs
Outdated
Show resolved
Hide resolved
| foreach (var testCase in _unobservedExceptionTrackingTestCase) | ||
| { | ||
| var unobservedExceptionTestCaseRunSummary = await RunTestCollectionAsync( | ||
| messageBus, | ||
| testCase.TestMethod.TestClass.TestCollection, | ||
| [testCase], |
There was a problem hiding this comment.
The idea of this code was to make sure the _unobservedExceptionTrackingTestCase is being executed as the very last test case in the collection. We do not need to wrap with foreach, we should simply run all of them after the rest of tests are done.
Both EnsureNoUnobservedTaskException and EnsureNoUnobservedTaskException_Integration have the "UnobservedExceptionTracking" category. This means that the SingleOrDefault throws in test dicovery. I don't know that this is the correct fix, but it's a starting point.
|
Updated to run only one if more than one test exists. |
Both EnsureNoUnobservedTaskException and EnsureNoUnobservedTaskException_Integration have the "UnobservedExceptionTracking" category. This means that the SingleOrDefault throws in test dicovery.
I don't know that this is the correct fix, but it's a starting point.