We have a bunch of generators specified in a class.
class MyUsefulGenerators {
@Provide
public Arbitrary<String> someDomainSpecificThing() {
...
}
}
They're broadly useful, so I'd like to be able to use them in different test classes other than where they're specified. For example:
class MyTestClass {
@Property
void testThing(@ForAll("someDomainSpecificThing") String thing) {
...
}
}
However, jqwik is unable to discover this Provider since it lives outside of the current class. I can, of course, manually import the provider from the other class and setup a new provider in this one, but that all feels a bit crufty.
Is there a way to directly use a Provider specified in another file?
jqwik's mechanism for provider sharing is called "Domains". There's a whole chapter on it in jqwik's user guide.
In your example you could introduce a domain context class like this:
and then use the context in your property: