-
Notifications
You must be signed in to change notification settings - Fork 641
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
Added RepeatAttribute that is aware of RandomizedContext #1125
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…: Only create an instance of TestResult if it is not already instantiated.
…zedContext aware. Added tests from NUnit to verify it passes RepeatAttribute tests.
…files that were copied from those libraries
…sserts to ensure the random seed and test seed in RandomizedContext are being updated consistently and correctly
…class checking and a test to ensure that we receive the correct result
…stFramework.NUnitExtensions
…nsions workflow file
…SetResultErrorNonLuceneTestCaseSubclass
paulirwin
reviewed
Jan 27, 2025
src/dotnet/Lucene.Net.TestFramework.TestData.NUnit/TestUtilities/TestBuilder.cs
Show resolved
Hide resolved
paulirwin
approved these changes
Jan 27, 2025
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.
This looks great, nicely done. The actual implementation is refreshingly simple! (Although I'm sure the work to get there was not.) I left one comment that could be looked into, but not a must-have change.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the changes (Less than 80 chars)
Fixes #1106
Description
This creates a new
RepeatAttribute
that is nested withinLuceneTestCase
. In addition to repeating the test X number of times, this attribute ensures that each iteration resets the test seed onRandomizedContext.RandomGenerator
so failed test conditions can be replicated without the need to apply theRepeatAttribute
.This sets a precedent for how to test other NUnit extensions (such as attributes) so we can also add tests to confirm they behave as expected. Some bits of the NUnit test approach were added so we can integration test the
RepeatAttribute
to confirm the correct behavior. The commit cdfd62b includes additional asserts that verify:Note that
RepeatAttribute
does not repeat theOneTimeSetUp()
orOneTimeTearDown()
during each iteration, so every repeated try will use the same culture, time zone, similarity, and codec. Perhaps we can do that at some future point, but it is more complicated to maintain theTestExectutionContext
,RandomizedContext
and seeds to make that happen.The format of the random seed string has also changed to use 2 hexadecimal numbers separated by a
:
. However, existing seeds with one hexidecimal number can still be parsed to replicate test failures. This not only allows us to make features that update the seed, but also will make test replicability more stable across source code updates on tests.