Comments (21)
There’s indeed some inconsistency about how built-in arbitrary providers match types. I‘ll have a look at it.
from jqwik.
Fixed in 22af655
Available in 1.1.2-SNAPSHOT
from jqwik.
@tmohme Your approach with registering your own provider should also work. @BigRange
should be applicable as long as your own provider will create instances of type BigDecimalArbitrary
or BigIntegerArbitrary
respectively. If you want I can have a look at that code to see what the problem is.
from jqwik.
I'm wondering in what situations Kotlin produces the generic subtype, though. Might lead to quite a few type matching problems in various situations...
from jqwik.
Fixed in 22af655
Thx for the super fast reaction :)
Your approach with registering your own provider should also work.
Thx for the hint and your offer. As I already wrote, we were probably missing some knowledge (and persistence) here.
Next time we stumble upon some problems, we'll delve a bit deeper into the subject.
No need for you to invest your time when we are just too lazy to do our homework ;)
I'm wondering in what situations Kotlin produces the generic subtype, though.
I'll play a bit with IntelliJ's Kolin byte-code viewer tomorrow . . . maybe I find out something useful.
from jqwik.
I'm wondering in what situations Kotlin produces the generic subtype, though. Might lead to quite a few type matching problems in various situations...
Just found out that you can use @JvmSuppressWildcards(suppress = true)
on the test method to avoid this problem.
With this annotation in place the described problem does not exist.
from jqwik.
The change is more consistent anyway, And already deployed in 1.1.2. But good to know a workaround exists for future problems.
from jqwik.
Just got following on 1.1.6:
Jul 13, 2019 8:02:48 PM net.jqwik.engine.JqwikProperties loadProperties
INFO: No Jqwik properties file [jqwik.properties] found.
net.jqwik.api.CannotFindArbitraryException: Cannot find an Arbitrary for Parameter of type [@net.jqwik.api.ForAll(value=) @net.jqwik.api.constraints.Size(value=0, max=0, min=1) List<String>]
at net.jqwik.engine.properties.RandomizedShrinkablesGenerator.resolveParameter(RandomizedShrinkablesGenerator.java:33)
at net.jqwik.engine.properties.RandomizedShrinkablesGenerator.lambda$forParameters$0(RandomizedShrinkablesGenerator.java:21)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
at net.jqwik.engine.properties.RandomizedShrinkablesGenerator.forParameters(RandomizedShrinkablesGenerator.java:22)
at net.jqwik.engine.execution.CheckedProperty.createRandomizedShrinkablesGenerator(CheckedProperty.java:154)
at net.jqwik.engine.execution.CheckedProperty.createDefaultShrinkablesGenerator(CheckedProperty.java:94)
at net.jqwik.engine.execution.CheckedProperty.createShrinkablesGenerator(CheckedProperty.java:84)
at net.jqwik.engine.execution.CheckedProperty.createGenericProperty(CheckedProperty.java:70)
at net.jqwik.engine.execution.CheckedProperty.check(CheckedProperty.java:39)
at net.jqwik.engine.execution.PropertyMethodExecutor.executeProperty(PropertyMethodExecutor.java:132)
at net.jqwik.engine.execution.PropertyMethodExecutor.executeMethod(PropertyMethodExecutor.java:120)
at net.jqwik.engine.execution.PropertyMethodExecutor.lambda$executePropertyMethod$2(PropertyMethodExecutor.java:100)
at net.jqwik.api.lifecycle.AroundPropertyHook.lambda$static$0(AroundPropertyHook.java:17)
at net.jqwik.api.lifecycle.AroundPropertyHook.lambda$null$1(AroundPropertyHook.java:32)
at net.jqwik.engine.execution.lifecycle.AutoCloseableHook.aroundProperty(AutoCloseableHook.java:14)
at net.jqwik.api.lifecycle.AroundPropertyHook.lambda$around$2(AroundPropertyHook.java:37)
at net.jqwik.engine.execution.PropertyMethodExecutor.executePropertyMethod(PropertyMethodExecutor.java:98)
at net.jqwik.engine.execution.PropertyMethodExecutor.execute(PropertyMethodExecutor.java:44)
at net.jqwik.engine.execution.PropertyTaskCreator.executeTestMethod(PropertyTaskCreator.java:79)
at net.jqwik.engine.execution.PropertyTaskCreator.lambda$createTask$0(PropertyTaskCreator.java:38)
at net.jqwik.engine.execution.pipeline.ExecutionTask$1.execute(ExecutionTask.java:24)
at net.jqwik.engine.execution.pipeline.ExecutionPipeline.runToTermination(ExecutionPipeline.java:81)
at net.jqwik.engine.execution.JqwikExecutor.execute(JqwikExecutor.java:46)
at net.jqwik.engine.JqwikTestEngine.executeTests(JqwikTestEngine.java:68)
at net.jqwik.engine.JqwikTestEngine.execute(JqwikTestEngine.java:57)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
when signature is as following:
@Property
fun test(@ForAll @Size(min = 1) names: List<@StringLength(min = 1, max = 20) String>) {
Assertions.assertEquals(names.toSet().joinToString(separator = ", "), CatalogUtils.toShortForm(names))
}
from jqwik.
@asm0dey Looking at the stack trace it should work, so
Since I'm not a Kotlin user: Can you point me to the simplest startup project (Gradle preferred) with which I can test it? And did you try @JvmSuppressWildcards(suppress = true) mentioned earlier in this thread?
from jqwik.
I have maven only and I'll try to narrow it down to minimum reproducible example .
And yes, I've tried to add annotation, no luck
from jqwik.
For me, the following slightly modified snippet runs flawlessly with Kolin 1.3.41, jqwik 1.1.6, Gradle 5.5.1:
@Property
fun test(@ForAll @Size(min = 1) names: List<@StringLength(min = 1, max = 20) String>) {
// Assertions.assertEquals(names.toSet().joinToString(separator = ", "), CatalogUtils.toShortForm(names))
}
I guess a complete example-project is required to investigate this.
from jqwik.
Just a wild guess: Could it be that Kotlin's nullable type feature leads to a type mismatch with Java's standard types?
from jqwik.
It could! I had to say that my code under test is written in Java. Does it change anything?
from jqwik.
If I only knew. Actually I'll need a repo in order to debug the live running code and see what's going on.
from jqwik.
And I'm absolutely unable to create simple example :(
from jqwik.
Start with giving the full code including class declaration and all imports. Maybe we can work from there.
from jqwik.
It all starts here: https://github.com/php-coder/mystamps/blob/712c62384be3decb641e8993a8223f01b30d2f29/src/main/java/ru/mystamps/web/util/CatalogUtils.java#L72
I've tried to add tests written in kotlin with jqwik to this method
from jqwik.
@asm0dey I cannot find the tests in the repository which are probably the crucial part for tracking the problem.
My current inkling is that your project setup is not correct. If, for example, module jqwik-engine
is not correctly inserted into the classpath the default arbitrary providers won't be loaded through Java's service loading mechanism which would materialize in the error you observed.
Maybe you can start from https://github.com/junit-team/junit5-samples/tree/r5.5.0/junit5-jupiter-starter-gradle-kotlin and then add jqwik as another testImplementation-dependency.
from jqwik.
Yeah, I didn't commit tests because they didn't work :) Anyways, I'll recheck everything again and will back to you if won't able to fix. Thank you!
from jqwik.
@asm0dey Any new insights?
from jqwik.
Nop. I think we should close this task until I have time to investigate
from jqwik.
Related Issues (20)
- StackOverflowError when shrinking large arrays HOT 14
- question: any way to imperatively summon a pre-configured arbitrary? HOT 15
- Make nested groups work for JDK >= 18 HOT 31
- Combinators.combine.as nullability of arguments HOT 4
- Can't figure out how to create an Arbitrary I want HOT 10
- Bug: Arbitraries.strings().uniqueChars() will sometimes shrink to values with duplicate chars HOT 5
- Bug: Uniform Distribution of Integers does not work if range is >= Integer.MAX_VALUE HOT 2
- Kotlin K2 Support HOT 24
- Time Module: Support generating java.sql.Timestamp
- adding `jqwik-kotlin` causes existing tests written in java to fail with NPE HOT 18
- Potential idea for running `SAMPLE_FIRST`/`SAMPLE_ONLY` for stateful tests HOT 2
- Lifecycle method called twice when subclassing HOT 4
- Cannot use Arbitrary.generator() outside jqwik HOT 6
- Is Arbitrary<@Nullable T> correct/intended under JSpecify semantics? HOT 32
- TypeUsage example from user guide fails in 1.8.x HOT 8
- Right Way to Integrate jqwik with DataFaker HOT 23
- Generic @Provide methods are sensitive to the type variables' names HOT 3
- Allowing Sampling of Arbitraries with Injected Seed HOT 4
- TestEngine with ID 'jqwik' failed to discover tests [BUG] HOT 4
- `@Spy` fields initalized by `closable = MockitoAnnotations.openMocks(this)` is not cleared by `closable.close()` for Jqwik HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jqwik.