-
Notifications
You must be signed in to change notification settings - Fork 723
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
RepeatAttribute increments CurrentRepeatCount on each repeat iteration #3696
Conversation
Increase CurrentRepeatCount in the RepeatAttribute
There is an CI issue although all tests are green. |
@Antash I've just retriggered builds on master and there we also fail with the same error. Some googling indicates that setting |
@mikkelbu thank you for the investigation! Hope someone from the team will fix this soon, don't feel confident enough to change anything there on my own. |
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 have PR that should solve the CI problem (even though I still not sure exactly what the problem is - which is very annoying).
Regarding this PR then I've left some comments, but the implementation seems sound. Besides this I also think we should update nunit/src/NUnitFramework/framework/TestContext.cs as it currently contains a TODO and some comments which are no longer correct (I don't know why the initial implementation left this part undone given the property name "CurrentRepeatCount" - but I cannot find any mention of the TODO in neither the issue #2647 nor the resolving PR #2648)
nunit/src/NUnitFramework/framework/TestContext.cs
Lines 173 to 181 in ad49f27
/// <summary> | |
/// Get the number of times the current Test has been repeated. This is currently only | |
/// set when using the <see cref="RetryAttribute"/>. | |
/// TODO: add this to the RepeatAttribute as well | |
/// </summary> | |
public int CurrentRepeatCount | |
{ | |
get { return _testExecutionContext.CurrentRepeatCount; } | |
} |
public void RepeatUpdatesCurrentRepeatCountPropertyOnEachAttempt() | ||
{ | ||
RepeatingTestsFixtureBase fixture = (RepeatingTestsFixtureBase)Reflect.Construct(typeof(RepeatedTestVerifyAttempt)); | ||
ITestResult result = TestBuilder.RunTestCase(fixture, "PassesTwoTimes"); |
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.
ITestResult result = TestBuilder.RunTestCase(fixture, "PassesTwoTimes"); | |
ITestResult result = TestBuilder.RunTestCase(fixture, nameof(RepeatedTestVerifyAttempt.PassesTwoTimes)); |
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.
Done. No Idea why I decided to ignore nameof. May be I was looking into existing RetryAttributeTests which uses plane strings either.
public void RepeatUpdatesCurrentRepeatCountPropertyOnGreenTest() | ||
{ | ||
RepeatingTestsFixtureBase fixture = (RepeatingTestsFixtureBase)Reflect.Construct(typeof(RepeatedTestVerifyAttempt)); | ||
ITestResult result = TestBuilder.RunTestCase(fixture, "AlwaysPasses"); |
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.
ITestResult result = TestBuilder.RunTestCase(fixture, "AlwaysPasses"); | |
ITestResult result = TestBuilder.RunTestCase(fixture, nameof(RepeatedTestVerifyAttempt.AlwaysPasses)); |
…ash-issue-3662
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.
Merge latest from master
@rprouse thank you! All green now. |
Closes #3662
RepeatAttribute should be incrementing the test context CurrentRepeatCount property for the sake of consistency.