Skip to content
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

Document RetryBaseAttribute/RetryAttribute introduced in MSTest 3.8 #44635

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jan 31, 2025

@Youssef1313 Youssef1313 requested review from IEvangelist and a team as code owners January 31, 2025 11:39
@dotnetrepoman dotnetrepoman bot added this to the January 2025 milestone Jan 31, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Jan 31, 2025
Comment on lines 356 to 365
### `RetryBaseAttribute`

The `RetryBaseAttribute` was introduced in MSTest 3.8. It's an abstract attribute that encapsulates a retry logic to be used when a test fails or timeouts. Implementors of this attribute must implement `ExecuteAsync` method which takes `RetryContext` as a parameter. Whenever a test times out or fails and an implementation of `RetryBaseAttribute` is present on the test method, MSTest will call `ExecuteAsync` of the attribute.

> [!NOTE]
> `RetryBaseAttribute.ExecuteAsync` is currently marked as experimental API.
>
> [!NOTE]
> MSTest provides a built-in implementation of `RetryBaseAttribute`, named `RetryAttribute`.
> The built-in `RetryAttribute` allows to control the maximum number of retry attempts, time delay between retries, and a delay backoff type which is either constant or exponential. You can check out the implementation of `RetryAttribute` on [GitHub](https://github.com/microsoft/testfx/blob/27e0f3da163f3cd651e34395c8759772012b55f9/src/TestFramework/TestFramework/Attributes/TestMethod/RetryAttribute.cs) to have better understanding of how to implement your own custom `RetryBaseAttribute`.
Copy link
Member

Choose a reason for hiding this comment

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

I would probably do the opposite and describe here RetryAttribute that is what is useful to end users. We can mention RetryBaseAttribute in a note saying that it allows for user-provided attributes or we could just not mention it here and add a new documentation page about MSTest extensibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Evangelink Does it look better now?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe drop the first note

Copy link
Member Author

Choose a reason for hiding this comment

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

@Evangelink Which note? About experimental? That one is already dropped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document RetryAttribute in dotnet/docs
2 participants