Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fluffynuts/nunit-retry-with-timeout
Provides a test decorator, [RetryWithTimeout(...)] which allows retrying tests with per-test and overall timeouts, working around a common problem with [Retry(...)] and [Timeout(...)] being on the same test
https://github.com/fluffynuts/nunit-retry-with-timeout
Last synced: 19 days ago
JSON representation
Provides a test decorator, [RetryWithTimeout(...)] which allows retrying tests with per-test and overall timeouts, working around a common problem with [Retry(...)] and [Timeout(...)] being on the same test
- Host: GitHub
- URL: https://github.com/fluffynuts/nunit-retry-with-timeout
- Owner: fluffynuts
- License: bsd-3-clause
- Created: 2023-10-16T16:28:55.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-20T10:00:06.000Z (over 1 year ago)
- Last Synced: 2024-11-13T18:32:09.449Z (2 months ago)
- Language: C#
- Size: 96.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nunit-retry-with-timeout
Provides a test decorator, `[RetryWithTimeout(...)]` which allows retrying tests with per-test
and overall timeouts, working around a common problem with `[Retry(...)]` and `[Timeout(...)]`
being on the same test.examples:
The most common one: you'd like to retry a test if it fails, and only allow
a certain amount of time per test attempt. Currently, with NUnit, if the `[Timeout]`
attribute causes a test to fail due to timeout, `[Retry]` is essentially ignored.Also, NUnit's [Retry] only retries on AssertionExceptions - not if some other
exception is thrown, which is particularly annoying if you're using an assertions
framework other than NUnit's, because you have to wrap the entire test in
```csharp
Assert.That(() =>
{
... // original test code
}, Throws.Nothing
);
```Instead, try:
```csharp
/*
* Retries the test up to 3 times, after _any_ exception, not just NUnit exceptions,
* with a per-test timeout of 5 seconds.
*/
[RetryWithTimeout(3, 5000)]
[Test]
public void SomeFlakyTest()
{
}
```There's also an edge case for when you'd like to allow up to a certain amount of time
per test, but less time than `retries` x `timeout` for the overall test, eg a test
which passes most of the time, but _sometimes_ hangs, perhaps due to network issues:```csharp
/*
* Retries the test up to 3 times, with a per-test
* timeout of 2 seconds and an overall timeout of
* 5 seconds - so if the first two attempts fail,
* the last one will essentially have only 1s to run
*/
[RetryWithTimeout(3, 2000, 5000)]
[Test]
public void AnotherFlakyTest()
{
}```