Skip to content

Conversation

@cfuerbachersparks
Copy link
Contributor

@cfuerbachersparks cfuerbachersparks commented Oct 29, 2024

Changes to always repeat a test x times.
Fixes #4861.

@cfuerbachersparks
Copy link
Contributor Author

@dotnet-policy-service agree company="Sparks Solutions GmbH"

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

Thanks @cfuerbachersparks. The actual change to functionality and tests looks good.
I have 2 requests for changes, see individual comments.

/// <param name="count">The number of times to run the test</param>
public RepeatAttribute(int count) : base(count)
/// <param name="stopOnFailure">Whether to stop when a test is not successful or not</param>
public RepeatAttribute(int count, bool stopOnFailure = true) : base(count)
Copy link
Member

Choose a reason for hiding this comment

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

This is non-backward change for already compiled code. You need to keep the original constructor, it can call the new ones. This also means you have to make the stopOnFailure parameter non-optional in the new constructor.

Personally, I prefer a syntax where I can say: [Repeat(5, StopOnFailure = true)] as a clear indication what the boolean means. You can add a StopOnFailure property so users can choose which way they prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made StopOnFailure a property, restored old ctor and created a new one with non-optional parameter

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

Thanks @cfuerbachersparks.

One more item, can you add a unit test which uses the attribute and sets the StopOnError property, one each for false and true

@cfuerbachersparks
Copy link
Contributor Author

Thanks @cfuerbachersparks.

One more item, can you add a unit test which uses the attribute and sets the StopOnError property, one each for false and true

added two unit tests

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. Looks good now.

@manfred-brands manfred-brands merged commit 195fb1a into nunit:main Nov 13, 2024
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.

Always repeat Test x times

2 participants