You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Arbitraries.forType() method, there is NPE exception, when it is used outside of jqwik test runner (i.e. in junit 5 default, jupiter, runner).
Stacktrace:
java.lang.NullPointerException
at net.jqwik.engine.facades.ArbitrariesFacadeImpl.allDefaultsFor(ArbitrariesFacadeImpl.java:196)
at net.jqwik.engine.facades.ArbitrariesFacadeImpl.lambda$defaultFor$3(ArbitrariesFacadeImpl.java:164)
at net.jqwik.engine.properties.arbitraries.LazyArbitrary.generator(LazyArbitrary.java:18)
at net.jqwik.api.Combinators$ListCombinator$1.lambda$generator$0(Combinators.java:697)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at net.jqwik.api.Combinators$ListCombinator$1.generator(Combinators.java:698)
at net.jqwik.engine.properties.arbitraries.IgnoreGenerationErrorArbitrary.generator(IgnoreGenerationErrorArbitrary.java:18)
at net.jqwik.engine.properties.shrinking.FlatMappedShrinkable.lambda$new$0(FlatMappedShrinkable.java:17)
at net.jqwik.engine.properties.shrinking.FlatMappedShrinkable.generateShrinkable(FlatMappedShrinkable.java:29)
at net.jqwik.engine.properties.shrinking.FlatMappedShrinkable.<init>(FlatMappedShrinkable.java:24)
at net.jqwik.engine.properties.shrinking.FlatMappedShrinkable.<init>(FlatMappedShrinkable.java:17)
at net.jqwik.engine.facades.RandomGeneratorFacadeImpl.flatMap(RandomGeneratorFacadeImpl.java:21)
at net.jqwik.api.RandomGenerator.lambda$flatMap$2(RandomGenerator.java:58)
Test code throwing exception is something like this:
I would check, if forType is called in right context (i.e. correct test engine executor) and throw some more informative exception.
Perhaps in DefaultTypeArbitrary constructor would be a nice place. Other imho valid place could be in DomainContextFacadeImpl. Change its static property called currentContext into "static getter" and check for valid value in thread local there.
Discussion
I am not aware if jqwik internal code hierarchy, so not much here from me. I would just suggest to document for jqwik engine in forType javadoc. (I can try to make pull request for this if you like).
The text was updated successfully, but these errors were encountered:
There could be a (somewhat) useful behaviour outside a property: Just using the global domain context, i.e. use all globally registered arbitrary providers. I might implement that...
Testing Problem
When using
Arbitraries.forType()
method, there is NPE exception, when it is used outside of jqwik test runner (i.e. in junit 5 default, jupiter, runner).Stacktrace:
Test code throwing exception is something like this:
Problem is test engine. I have also one property based test, which is passing ok. Here it is:
Suggested Solution
I would check, if forType is called in right context (i.e. correct test engine executor) and throw some more informative exception.
Perhaps in
DefaultTypeArbitrary
constructor would be a nice place. Other imho valid place could be inDomainContextFacadeImpl
. Change its static property calledcurrentContext
into "static getter" and check for valid value in thread local there.Discussion
I am not aware if jqwik internal code hierarchy, so not much here from me. I would just suggest to document for jqwik engine in forType javadoc. (I can try to make pull request for this if you like).
The text was updated successfully, but these errors were encountered: