Home > Back-end >  Get the Minitest seed value programmatically
Get the Minitest seed value programmatically

Time:01-25

In RSpec I would use the following to obtain a Random which is seeded from the test order random seed. This would give us a reproducible RNG for things like fuzzing:

reproducible_random = Random.new(RSpec.configuration.seed)

Now that I am working with a project that uses Minitest (the Rails default) I can't seem to find how to obtain the Minitest seed value and produce a reproducible test. Is there a way to access it someplace from inside the tests themselves?

CodePudding user response:

There is an open issue about it in mintest from 2016.

I believe as of now it is not possible.

CodePudding user response:

You can use the --seed parameter when calling minitest or the SEED environment variable, [source code](https://github.com/seattlerb/minitest/blob/fe3992e85b40792cf7bff2a876887d8d9e392068/lib/minitest.rb#L190

  •  Tags:  
  • Related