Skip to content

Commit

Permalink
Add xRetry.Reqnroll to docs
Browse files Browse the repository at this point in the history
Note that it's a copy/paste of xRetry.SpecFlow, but having its own section is intentional. If Reqnroll is actively developed, the instructions to use both frameworks may be identical today, but could drift over time.
  • Loading branch information
JoshKeegan committed May 23, 2024
1 parent e904af8 commit 3487d41
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 49 deletions.
135 changes: 90 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Retry flickering test cases for xUnit and SpecFlow in .NET.

[![pipeline status](https://github.com/JoshKeegan/xRetry/actions/workflows/cicd.yaml/badge.svg)](https://github.com/JoshKeegan/xRetry/actions)
[![xRetry NuGet package](https://buildstats.info/nuget/xRetry)](https://www.nuget.org/packages/xRetry "Download xRetry from NuGet")
[![xRetry.SpecFlow NuGet package](https://buildstats.info/nuget/xRetry.SpecFlow?includePreReleases=true)](https://www.nuget.org/packages/xRetry.SpecFlow "Download xRetry.SpecFlow from NuGet")
[![xRetry.SpecFlow NuGet package](https://buildstats.info/nuget/xRetry.SpecFlow)](https://www.nuget.org/packages/xRetry.SpecFlow "Download xRetry.SpecFlow from NuGet")
[![xRetry.Reqnroll NuGet package](https://buildstats.info/nuget/xRetry.Reqnroll)](https://www.nuget.org/packages/xRetry.SpecFlow "Download xRetry.Reqnroll from NuGet")


[//]: \# (Src: whenToUse.md)
Expand All @@ -30,50 +31,6 @@ This is the intended use case of the library.
If you have a test that covers some flaky code, where sporadic failures are caused by a bug,
this library should **not** be used to cover it up!

[//]: \# (Src: xRetry.SpecFlow/usage.md)

## Usage: SpecFlow 3

Add the [`xRetry.SpecFlow` NuGet package](https://www.nuget.org/packages/xRetry.SpecFlow "xRetry NuGet.SpecFlow package") to your project.

### Scenarios (and outlines)

Above any scenario or scenario outline that should be retried, add a `@retry` tag, e.g:

```gherkin
@retry
Scenario: Retry three times by default
When I increment the default retry count
Then the default result should be 3
```

This will attempt to run the test until it passes, up to 3 times by default.
You can optionally specify a number of times to attempt to run the test in brackets, e.g. `@retry(5)`.

You can also optionally specify a delay between each retry (in milliseconds) as a second
parameter, e.g. `@retry(5,100)` will run your test up to 5 times, waiting 100ms between each attempt.
Note that you must not include a space between the parameters, as Cucumber/SpecFlow uses
a space to separate tags, i.e. `@retry(5, 100)` would not work due to the space after the comma.

### Features

You can also make every test in a feature retryable by adding the `@retry` tag to the feature, e.g:

```gherkin
@retry
Feature: Retryable Feature
Scenario: Retry scenario three times by default
When I increment the retry count
Then the result should be 3
```

All options that can be used against an individual scenario can also be applied like this at the feature level.
If a `@retry` tag exists on both the feature and a scenario within that feature, the tag on the scenario will take
precedent over the one on the feature. This is useful if you wanted all scenarios in a feature to be retried
by default but for some cases also wanted to wait some time before each retry attempt. You can also use this to prevent a specific scenario not be retried, even though it is within a feature with a `@retry` tag, by adding `@retry(1)` to the scenario.


[//]: \# (Src: xRetry/usage.md)

## Usage: xUnit
Expand Down Expand Up @@ -151,6 +108,94 @@ type that is used by that library to the `RetryFact`. e.g. if you are using the
test is as simple as replacing `[SkippableFact]` with `[RetryFact(typeof(Xunit.SkipException))]` above the test and you don't need to change the test itself.


[//]: \# (Src: xRetry.SpecFlow/usage.md)

## Usage: SpecFlow 3

Add the [`xRetry.SpecFlow` NuGet package](https://www.nuget.org/packages/xRetry.SpecFlow "xRetry NuGet.SpecFlow package") to your project.

### Scenarios (and outlines)

Above any scenario or scenario outline that should be retried, add a `@retry` tag, e.g:

```gherkin
@retry
Scenario: Retry three times by default
When I increment the default retry count
Then the default result should be 3
```

This will attempt to run the test until it passes, up to 3 times by default.
You can optionally specify a number of times to attempt to run the test in brackets, e.g. `@retry(5)`.

You can also optionally specify a delay between each retry (in milliseconds) as a second
parameter, e.g. `@retry(5,100)` will run your test up to 5 times, waiting 100ms between each attempt.
Note that you must not include a space between the parameters, as Cucumber/SpecFlow uses
a space to separate tags, i.e. `@retry(5, 100)` would not work due to the space after the comma.

### Features

You can also make every test in a feature retryable by adding the `@retry` tag to the feature, e.g:

```gherkin
@retry
Feature: Retryable Feature
Scenario: Retry scenario three times by default
When I increment the retry count
Then the result should be 3
```

All options that can be used against an individual scenario can also be applied like this at the feature level.
If a `@retry` tag exists on both the feature and a scenario within that feature, the tag on the scenario will take
precedent over the one on the feature. This is useful if you wanted all scenarios in a feature to be retried
by default but for some cases also wanted to wait some time before each retry attempt. You can also use this to prevent a specific scenario not be retried, even though it is within a feature with a `@retry` tag, by adding `@retry(1)` to the scenario.


[//]: \# (Src: xRetry.Reqnroll/usage.md)

## Usage: Reqnroll 2

Add the [`xRetry.Reqnroll` NuGet package](https://www.nuget.org/packages/xRetry.Reqnroll "xRetry NuGet.Reqnroll package") to your project.

### Scenarios (and outlines)

Above any scenario or scenario outline that should be retried, add a `@retry` tag, e.g:

```gherkin
@retry
Scenario: Retry three times by default
When I increment the default retry count
Then the default result should be 3
```

This will attempt to run the test until it passes, up to 3 times by default.
You can optionally specify a number of times to attempt to run the test in brackets, e.g. `@retry(5)`.

You can also optionally specify a delay between each retry (in milliseconds) as a second
parameter, e.g. `@retry(5,100)` will run your test up to 5 times, waiting 100ms between each attempt.
Note that you must not include a space between the parameters, as Cucumber/Reqnroll uses
a space to separate tags, i.e. `@retry(5, 100)` would not work due to the space after the comma.

### Features

You can also make every test in a feature retryable by adding the `@retry` tag to the feature, e.g:

```gherkin
@retry
Feature: Retryable Feature
Scenario: Retry scenario three times by default
When I increment the retry count
Then the result should be 3
```

All options that can be used against an individual scenario can also be applied like this at the feature level.
If a `@retry` tag exists on both the feature and a scenario within that feature, the tag on the scenario will take
precedent over the one on the feature. This is useful if you wanted all scenarios in a feature to be retried
by default but for some cases also wanted to wait some time before each retry attempt. You can also use this to prevent a specific scenario not be retried, even though it is within a feature with a `@retry` tag, by adding `@retry(1)` to the scenario.


[//]: \# (Src: logs.md)

## Viewing retry logs
Expand Down
15 changes: 13 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ repo:
$(call append,ciBadge.md,../README.md,0)
$(call append,nugetBadges.md,../README.md,1)
$(call append,whenToUse.md,../README.md,0)
$(call append,xRetry.SpecFlow/usage.md,../README.md,0)
$(call append,xRetry/usage.md,../README.md,0)
$(call append,xRetry.SpecFlow/usage.md,../README.md,0)
$(call append,xRetry.Reqnroll/usage.md,../README.md,0)
$(call append,logs.md,../README.md,0)
$(call append,contributing.md,../README.md,0)
$(call append,repo/footer.md,../README.md,0)
Expand All @@ -45,5 +46,15 @@ xRetry.SpecFlow:
$(call append,logs.md,../src/xRetry.SpecFlow/README.md,0)
$(call append,issues.md,../src/xRetry.SpecFlow/README.md,0)

.PHONY: xRetry.Reqnroll
xRetry.Reqnroll:
echo $(GENERATED_DISCLAIMER) > ../src/xRetry.Reqnroll/README.md
$(call append,xRetry.Reqnroll/header.md,../src/xRetry.Reqnroll/README.md,0)
$(call append,ciBadge.md,../src/xRetry.Reqnroll/README.md,0)
$(call append,whenToUse.md,../src/xRetry.Reqnroll/README.md,0)
$(call append,xRetry.Reqnroll/usage.md,../src/xRetry.Reqnroll/README.md,0)
$(call append,logs.md,../src/xRetry.Reqnroll/README.md,0)
$(call append,issues.md,../src/xRetry.Reqnroll/README.md,0)

.PHONY: all
all: repo xRetry xRetry.SpecFlow
all: repo xRetry xRetry.SpecFlow xRetry.Reqnroll
3 changes: 2 additions & 1 deletion docs/nugetBadges.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[![xRetry NuGet package](https://buildstats.info/nuget/xRetry)](https://www.nuget.org/packages/xRetry "Download xRetry from NuGet")
[![xRetry.SpecFlow NuGet package](https://buildstats.info/nuget/xRetry.SpecFlow?includePreReleases=true)](https://www.nuget.org/packages/xRetry.SpecFlow "Download xRetry.SpecFlow from NuGet")
[![xRetry.SpecFlow NuGet package](https://buildstats.info/nuget/xRetry.SpecFlow)](https://www.nuget.org/packages/xRetry.SpecFlow "Download xRetry.SpecFlow from NuGet")
[![xRetry.Reqnroll NuGet package](https://buildstats.info/nuget/xRetry.Reqnroll)](https://www.nuget.org/packages/xRetry.SpecFlow "Download xRetry.Reqnroll from NuGet")
2 changes: 2 additions & 0 deletions docs/xRetry.Reqnroll/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# xRetry.Reqnroll
Retry flickering test cases for Reqnroll when using xUnit.
40 changes: 40 additions & 0 deletions docs/xRetry.Reqnroll/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Usage: Reqnroll 2

Add the [`xRetry.Reqnroll` NuGet package](https://www.nuget.org/packages/xRetry.Reqnroll "xRetry NuGet.Reqnroll package") to your project.

### Scenarios (and outlines)

Above any scenario or scenario outline that should be retried, add a `@retry` tag, e.g:

```gherkin
@retry
Scenario: Retry three times by default
When I increment the default retry count
Then the default result should be 3
```

This will attempt to run the test until it passes, up to 3 times by default.
You can optionally specify a number of times to attempt to run the test in brackets, e.g. `@retry(5)`.

You can also optionally specify a delay between each retry (in milliseconds) as a second
parameter, e.g. `@retry(5,100)` will run your test up to 5 times, waiting 100ms between each attempt.
Note that you must not include a space between the parameters, as Cucumber/Reqnroll uses
a space to separate tags, i.e. `@retry(5, 100)` would not work due to the space after the comma.

### Features

You can also make every test in a feature retryable by adding the `@retry` tag to the feature, e.g:

```gherkin
@retry
Feature: Retryable Feature
Scenario: Retry scenario three times by default
When I increment the retry count
Then the result should be 3
```

All options that can be used against an individual scenario can also be applied like this at the feature level.
If a `@retry` tag exists on both the feature and a scenario within that feature, the tag on the scenario will take
precedent over the one on the feature. This is useful if you wanted all scenarios in a feature to be retried
by default but for some cases also wanted to wait some time before each retry attempt. You can also use this to prevent a specific scenario not be retried, even though it is within a feature with a `@retry` tag, by adding `@retry(1)` to the scenario.
2 changes: 1 addition & 1 deletion src/xRetry.Reqnroll/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ this library should **not** be used to cover it up!

[//]: \# (Src: xRetry.Reqnroll/usage.md)

## Usage: Reqnroll 3
## Usage: Reqnroll 2

Add the [`xRetry.Reqnroll` NuGet package](https://www.nuget.org/packages/xRetry.Reqnroll "xRetry NuGet.Reqnroll package") to your project.

Expand Down

0 comments on commit 3487d41

Please sign in to comment.