jqwik-team / jqwik

Property-Based Testing on the JUnit Platform

Home Page:http://jqwik.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use Arbitrary.generator() outside jqwik

translatenix opened this issue · comments

I'm trying to use Arbitrary.generator() outside jqwik, but it doesn't work. Is this a bug? jqwik 1.8.4.

var arbitrary = Arbitraries.strings();
var generator = arbitrary.generator(100);
net.jqwik.engine.execution.lifecycle.OutsideJqwikException: The current action must be run on a jqwik thread, i.e. container, property or hook.
Maybe you spawned off a thread?

Thanks, this looks great. Is there also a way to do shrinking outside jqwik?

Not realistically. Shrinking requires a lot of context; the code is all hidden in the engine module.
What‘s your use case?

I'm trying to add support for property-based testing to Pkl, and I'm hoping that jqwik will do the heavy lifting for me. :-)

https://pkl-lang.org/blog/testing-in-pkl.html

Don't know anything about pkl, but my assumption is that you'd have to wait for jqwik2, which will be much more generic.

Sounds good. For now this is just a POC, and copying/modifying parts of the jqwik source code is good enough.