Autobogus does not respect calls to Randomizer.Seed or UseSeed
See original GitHub issueUnit and integration tests should generally be deterministic (see here; with the potential exception of cases where one is specifically trying to implement randomized tests as a form of exploratory testing).
The base Bogus library provides for this as described here, namely either by:
- setting the
Randomizer.Seedglobal static property; or - calling the
Faker<T>.UseSeed(int)method.
However, Autobogus does not appear to respect either of these methods of deterministically creating fake data. I have tried both of the approaches without success, as exemplified below:
// Author class
public class Author
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
// Navigation properties
public ICollection<Book> Books { get; set; }
}
// Global seed configuration
Randomizer.Seed = new Random(8675309);
// Local seed configuration
const int seed = 1234;
var authorFaker = new AutoFaker<Author>()
.Configure(builder => builder
.WithSkip<Author>(a => a.Id)
.WithSkip<Author>(a => a.Books))
.UseSeed(seed);
// Check output using LINQPad
authorFaker.Generate().Dump();
In both cases, the data output differs on each run. If I use Bogus without Autobogus, I am able to create deterministic data without any issues.
Is it currently possible to generate deterministic data with Autobogus or, if not, is it possible to add this feature? Despite the library offering a lot of other useful features, currently we cannot use it because of a requirement to create deterministic data.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)

Top Related StackOverflow Question
Hey @zejji
I have updated the issue you reference in you comment. Currently the
UseSeedis not hooked up to the underlyingFakerused by theAutoFakerclass. I will get a change in place to make that so and let you know when it has been released.Nick.
Am I misunderstanding – by running the tests in parallel, aren’t they pulling numbers concurrently from the same underlying source??