Hi,
I'm wondering what the idiomatic way is to provide a seed for a unit test.
I'm planning on writing a small property test for a parser of mine. Since property tests are all about randomly sampling the input space, I need to provide a seed for the PRNGs involved.
Of course it is totally sufficient to introduce a constant somewhere in the module, but it would be nice if one could vary the seed at execution time to check if the sampling behaves oddly. But since the only way to get nondeterminism is via a platform, if I understand correctly that would mean I would have to switch from writing them with expect to writing them as a separate program on top of basic-cli, which I'd like to avoid.
Given my limited experience with roc, are there any other solutions at the moment?
Is there any idea around passing test context to roc test or similar?
Could you use a file import?
import "seed.txt" as seed : Str
test ... # use seed here
I haven't thought of file imports, that's a bit nicer that a constant buried somewhere. Still means I'll have to recompile, but let's see whether that actually is a problem in practice.
Lukas Juhrich has marked this topic as resolved.
Last updated: Mar 20 2026 at 12:28 UTC