Questions tagged [jqwik]
jqwik (pronounced "jay quick") is a library for performing property-based-testing (PBT) on JVM languages including Java, Kotlin and Groovy. Use this tag for questions about the jqwik library.
31
questions
0
votes
1
answer
15
views
Managing multiple arbitrary generators for various tests in PBT
I have many tests, which are using sample input files. Single file contains single example for some test. I would like to make tests to use jqwik for generating test data. From single example of hard-...
1
vote
1
answer
23
views
Constraining List values in jqwik with Kotlin
I'm writing jqwik tests in Kotlin. I have this parameter to one of my property tests:
@ForAll @Size(3) @UniqueElements emails: List<@Email @NotBlank String>
But when I run the test, it ...
2
votes
1
answer
38
views
Examples of larger/real-world PBT specs written in jqwik? [closed]
Is there a list of reverse dependencies to jqwik, i.e. other Java/Kotlin/Groovy libraries that use jqwik and, ideally, extensively? What are the more "mature" and extensive real-world (i.e. ...
0
votes
1
answer
143
views
How do I generate a positive list of integers in jqwik and Kotlin?
I have tried something like this, but seems like it's not working since I can see negatives in the generated list:
@Property
fun <testMethodName>(
@ForAll @Size(min = 0, max = 1_500)
@...
2
votes
1
answer
122
views
Property-based Testing support for Quarkus / Tech doku about the Quarkus test-engine
We have a Quarkus project in production. It runs fine but testing is a nightmare because of high complexity of the data structure and business logic.
We would like to add property-based testing to our ...
0
votes
1
answer
309
views
jqwik strategies for combining arbitraries
(Context: my background in property-based testing is mostly from scala's scalacheck library, the use of some of the types and annotations in jqwik feels a bit different and there are a couple ...
1
vote
1
answer
261
views
jqwik using @ForAll with collection in @Provide-annotated method
Having a hard time figuring out how to utilize @ForAll in jqwik on a @Provide function accepting a collection.
Consider:
// domain model
public class Name {
public final String first;
public final ...
1
vote
1
answer
159
views
Inject returns NULL when activating jqwik in Quarkus test
We want to introduce property-based testing into our Quarkus project, preferably with jqwik. We already got numerous test cases using junit jupiter. We also use CDI in out test cases.
Getting jqwik ...
0
votes
1
answer
57
views
A chain with Action.Dependent throws JqwikException: empty set of values
I am doing stateful testing using Jqwik. The problem I am facing is as follows:
The action chain contains a set of state dependent actions that can produce empty Arbitraries (example: no "pop&...
1
vote
2
answers
146
views
Better Arbitrary Number?
I need an Arbitrary java.lang.Number.
Here is what I came up with:
@Provide
Arbitrary<Number> numbers(){
return
Combinators.combine(
Arbitraries.integers()...
0
votes
1
answer
71
views
Difference between List<Action> and ActionSequence in jqwik
What exactly is the difference in between List<Action> and ActionSequence in jqwik.
In the doc of jqwik, ActionSequence is created using Arbitraries.sequences(...) and the List<Action> is ...
1
vote
1
answer
81
views
jqwik double generator cannot be represented with scale
when using "chained" double generators with jqwik I get a scale error message java.util.concurrent.ExecutionException: net.jqwik.api.JqwikException: Decimal value -1.6099999999999999 cannot ...
0
votes
1
answer
172
views
Is it possible to mix jqwik with mockito tests?
I'm working in a project which contains tests in mockito.
I need to add more tests to this file, so I added a simple jqwik test, but if I try to run all tests all mockito ones are ignored.
0
votes
2
answers
291
views
When to choose Example based testing and property based for Stateful Testing
I'm doing unit testing mostly these days for Android SDK in Android Studio and using Jqwik which is a Property-Based testing tool on the JUnit Platform.
While exploring the different test techniques ...
0
votes
2
answers
184
views
Jqwik: How to check if all possibilities is covered?
How to check if all possibilities (cartesian product of arguments) is covered in summary by N properties?
Some of them can be tested few times by different properties.
0
votes
1
answer
109
views
OutsideJqwikException on simple test case after 1.5.0+ upgrade
Testing Problem
I wrote the following sample code and run it on intelliJ and kept getting the same exception on v1.5.0+.
The same code works fine on 1.4.0 and lower...
This is the sample code I ...
0
votes
1
answer
187
views
How do you use a jqwik @Provider specified in another class as part of a @ForAll paramter?
We have a bunch of generators specified in a class.
class MyUsefulGenerators {
@Provide
public Arbitrary<String> someDomainSpecificThing() {
...
}
}
They're broadly useful,...
1
vote
1
answer
100
views
How to specify @ForAll non-zero integers?
How can I specify @ForAll non-zero integers (i.e. either include both positive and negative integers, or exclude 0 from the integer range)? I couldn't find anything from https://jqwik.net/docs/current/...
1
vote
1
answer
122
views
How can I pass parameters to @Provide?
Is there a way to pass parameters to @Provide? I want something equivalent to the following:
@Property
void test(@ForAll("charSequence", 2, 5) CharSequence cs) {
// test property on cs, ...
1
vote
1
answer
185
views
Looking for better ways to generate a list of edges for a graph in jqwik property testing framework
Currently I am using:
@Provide
Arbitrary<List<Tuple.Tuple3<Integer,Integer,Integer>>> edgeLists (
TypeUsage type, ArbitraryProvider.SubtypeProvider subtype) {
...
1
vote
1
answer
145
views
Arbitrary created with flatMap does not consider the filter
I am trying jqwik (version 1.5.1) and I read from the documentation that I can create an Arbitrary whose generated value depends on the one supplied by another Arbitrary, specifically using the ...
0
votes
1
answer
286
views
Is there an annotation for @NegativeOrZero / @PositiveOrZero annotation?
According to the jqwik documentation here: https://jqwik.net/docs/current/user-guide.html#integer-constraints it states the integer constraint annotations as:
@Positive: Numbers larger than 0. For ...
0
votes
1
answer
160
views
Is it possible to mix jqwik @Property methods and junit5 @Test methods in the same test file?
Im porting some Python code using hypothesis, and trying to keep the sources as close as possible. The python test file has both parameterized and non-parameterized methods. If I mark them all as @...
2
votes
1
answer
183
views
Is it reproducible to use Arbitrary.sample from within an Action?
We have a stateful test for an order system. There is an Arbitrary that will generate an Order object that has a number of LineItem's.
There are actions to:
Create an Order
Cancel a LineItem
The ...
1
vote
1
answer
389
views
Property based testing for a custom ordered list in Java
Given the following ordering requirement:
All strings starting with "foo" should be first.
All string starting with "bar" should be last.
Strings that do not start with "foo&...
1
vote
1
answer
431
views
jqwik pairs of sorted array with some element of it
Following code aims to generate random sorted array, and key as one element of that array. But I do not know the issue, the keys are not in the array?
@Provide
Arbitrary<Map<Integer, Integer[]&...
2
votes
1
answer
1k
views
How to generate a sorted array of numbers with jqwik
I am using java jqwik for property based testing, I want to generate sorted array, my code so far:
@Provide
Integer[] arrProvider() {
Arbitrary<Integer> integerArbitrary = Arbitraries....
3
votes
1
answer
445
views
jqwik - How are values for tests selected?
In the first example on the jkwik site, there is a generator that potentially generates a large number of values for "divisible by 3":
@Property
boolean every_third_element_starts_with_Fizz(@ForAll("...
1
vote
1
answer
454
views
jqwik - Arbitrary Map - Generate a random number of entries within a Map
This code works to generate a Single Map entry for elements. But I want to generate a random number of entries from within the Map using generateInputMapElements and
pass to the ...
2
votes
2
answers
834
views
How to write a jqwik generator method with nested generators
Using jqwik.net, trying to generate a Rule class with a a nested RuleConfig class inside it.
The RuleConfig class has a nested ruleProps which is a Map
The statusReturnedFromApplyingRule method ...
1
vote
1
answer
462
views
Run jqwik tests with Jupiter console launcher
For testing purposes (no pun intended) I run some tests outside the IDE or MAven using the Console Launcher that comes with JUnit Jupiter. It finds all the JUnit 4 (aka. Vintage) and JUnit 5 (aka. ...