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

[Feature]: Add support for per-scenario seed configuration #97

Open
tsv1 opened this issue Sep 22, 2024 · 0 comments
Open

[Feature]: Add support for per-scenario seed configuration #97

tsv1 opened this issue Sep 22, 2024 · 0 comments

Comments

@tsv1
Copy link
Member

tsv1 commented Sep 22, 2024

Summary:

Currently, the SeederPlugin allows for deterministic random behavior via global seeding options such as --seed and --fixed-seed. However, there is no flexibility for configuring seeds or the use_fixed_seed behavior at the scenario level. This feature request proposes the addition of a @seed decorator, which would allow users to set both a custom seed and the use_fixed_seed parameter for individual scenarios.

Proposed Solution:

Introduce a @seed decorator that supports both a custom seed and an optional use_fixed_seed parameter at the scenario level. This would provide flexibility for users to define:

  1. A specific seed for individual scenarios.
  2. Whether the seed should remain fixed across multiple executions of that scenario within the same test run.

This per-scenario configuration would override the global seed and use_fixed_seed settings for those specific scenarios.

The decorator would accept two parameters:

  • seed: A string that specifies the seed for the scenario.
  • use_fixed_seed: A boolean (optional) to indicate whether the seed should remain fixed for repeated runs of the scenario within the same test run.

Example Usage:

import vedro
from vedro import seed

@seed("custom-seed-123", use_fixed_seed=True)
class Scenario(vedro.Scenario):
    ...

In this example:

  • The Scenario is seeded with "custom-seed-123", ensuring deterministic random behavior.
  • The use_fixed_seed=True option ensures that the same seed will be used for each repetition of the scenario in a single test run, even if it's repeated multiple times.

If the use_fixed_seed parameter is not provided, it will default to the global setting, allowing flexibility without needing to redefine it for every scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant