Skip to content

Add global configuration#305

Draft
JoshKeegan wants to merge 1 commit into
masterfrom
global-config
Draft

Add global configuration#305
JoshKeegan wants to merge 1 commit into
masterfrom
global-config

Conversation

@JoshKeegan

@JoshKeegan JoshKeegan commented Apr 16, 2026

Copy link
Copy Markdown
Owner

Introduces project-wide defaults, with a new file xretry.json supporting maxRetries and delayBetweenRetriesMs for all test runners. Implements #77.

BDD test runners (SpecFlow, Reqnroll and Reqnroll on xUnit.v3) also have retryUntaggedScenarios. This becomes a way of making all scenarios retried by default, with no test changes required. This is only possible for the BDD tests, since the xUnit tests require use of different attributes (RetryFact/RetryTheory rather than Fact/Theory). Implements #78.

It felt logical to add retryUntaggedScenarios at the same time as global config, not as a separate change because once global config is introduced and you can configure maxRetries for the entire project, I expect people will try and use it without tagging individual features or scenarios. Having a property of the global config for this behaviour makes it clear, with examples in docs, and anyone who wants this can easily enable it.

Defaults are unchanged, i.e.:

max retries = 3
delay between attempts = 0
retry untagged scenarios = false

That keeps this a non-breaking change, and means when you add xRetry to any project it won't affect tests without you either opting-in on a per test/feature/scenario basis, or adding global config.

A schema should be added to the xretry.json file, including examples that people will copy so they get schema validation in their IDE. Will add this once it's in master so the URL isn't to a branch.

@JoshKeegan

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@JoshKeegan JoshKeegan marked this pull request as draft April 16, 2026 22:07
@JoshKeegan

JoshKeegan commented Apr 16, 2026

Copy link
Copy Markdown
Owner Author

Warning: included a breaking change by changing the named ctor parameters to instead be properties. Will need a major version bump when released. That's fine though as v3 is not out yet & for older ones a major bump to align stuff is ok.

The attribute property syntax makes this fine for end-users, but it switches from camelCase to TitleCase. This was done as the project level defaults makes ctor parameters a little painful, needing a magic value as the default for them to work, as we can't use the default values (3, 0) any more, since they should not override config.

@JoshKeegan

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e2249d15b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 87 to 90
public RetryFactAttribute(
int maxRetries = DEFAULT_MAX_RETRIES,
int delayBetweenRetriesMs = DEFAULT_DELAY_BETWEEN_RETRIES_MS,
int maxRetries,
int delayBetweenRetriesMs,
params Type[] skipOnExceptions)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve optional-argument constructor compatibility

Changing this constructor to require both positional integers breaks existing source that used the previously supported optional-argument form like [RetryFact(delayBetweenRetriesMs: 100)] (and the analogous RetryTheory form), which now fails to compile after upgrading. This is a user-facing source compatibility regression for callers that only wanted to override delay, so an overload or compatible signature should be kept to avoid breaking existing test projects.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Not possible because the fallbacks are no longer compile-time constants. They could come from the global config instead.

This new way to do this is to set the public property, e.g. [RetryFact(DelayBetweenRetriesMs = 100)]. That works with the global config or the constants if there's no global config, and it just as easy to use.

This is a (minor) breaking change though & will need a mention in the release notes.

@JoshKeegan JoshKeegan force-pushed the global-config branch 2 times, most recently from ab89d32 to 8acac23 Compare April 23, 2026 18:32
Introduces project-wide defaults, with a new file `xretry.json` supporting maxRetries and delayBetweenRetriesMs for all test runners. Implements #77.

BDD test runners (SpecFlow, Reqnroll and Reqnroll on xUnit.v3) also have retryUntaggedScenarios. This becomes a way of making all scenarios retried by default, with no test changes required. This is only possible for the BDD tests, since the xUnit tests require use of different attributes (RetryFact/RetryTheory rather than Fact/Theory). Implements #78.

It felt logical to add retryUntaggedScenarios at the same time as global config, not as a separate change because once global config is introduced and you can configure maxRetries for the entire project, I expect people will try and use it without tagging individual features or scenarios. Having a property of the global config for this behaviour makes it clear, with examples in docs, and anyone who wants this can easily enable it.

Defaults are unchanged, i.e.:
max retries = 3
delay between attempts = 0
retry untagged scenarios = false
That keeps this a non-breaking change, and means when you add xRetry to any project it won't affect tests without you either opting-in on a per test/feature/scenario basis, or adding global config.

A schema should be added to the xretry.json file, including examples that people will copy so they get schema validation in their IDE. Will add this once it's in master so the URL isn't to a branch.
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.

1 participant