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.

jqwik is a property-based testing framework for the JVM. It is annotation-based and runs as test engine on the junit 5 platform. Just like its famous ancestor quickcheck jqwik generates test input data for test cases provided by the programmer. Documentation can be found on https://jqwik.net.

28 questions
3
votes
1 answer

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("divisibleBy3") int i) { return…
David Tanzer
  • 2,732
  • 18
  • 30
2
votes
1 answer

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 project. I have so far failed to find a Java PBT…
aaberg
  • 21
  • 2
2
votes
1 answer

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 action to create an order takes the order itself,…
osi
  • 207
  • 1
  • 6
2
votes
1 answer

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 integerArbitrary = Arbitraries.integers().between(0, 100); Arbitrary
rima.j
  • 31
  • 2
2
votes
2 answers

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 always returns an initialized Rule instead of using…
Vijay
  • 595
  • 1
  • 13
  • 27
1
vote
1 answer

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 String last; public Name(String f, String l) {…
drobert
  • 1,230
  • 8
  • 21
1
vote
2 answers

Better Arbitrary Number?

I need an Arbitrary java.lang.Number. Here is what I came up with: @Provide Arbitrary numbers(){ return Combinators.combine( Arbitraries.integers().between(0, 5), …
Gabriel
  • 1,679
  • 3
  • 16
  • 37
1
vote
1 answer

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 be represented with scale 4.. Can you provide me with some…
Antonin
  • 879
  • 2
  • 10
  • 27
1
vote
1 answer

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/user-guide.html#integer-constraints.
Leponzo
  • 624
  • 1
  • 8
  • 20
1
vote
1 answer

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, which is an arbitrary CharSequence of length minimum 2 and…
Leponzo
  • 624
  • 1
  • 8
  • 20
1
vote
1 answer

Looking for better ways to generate a list of edges for a graph in jqwik property testing framework

Currently I am using: @Provide Arbitrary>> edgeLists ( TypeUsage type, ArbitraryProvider.SubtypeProvider subtype) { int vertices = 10; int degree_min = 1; int…
1
vote
1 answer

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 flatMap function. My actual goal is different, but…
Marco Luzzara
  • 5,540
  • 3
  • 16
  • 42
1
vote
1 answer

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" or "bar" can also be present in the list. How can one use Property-Based…
Erez Ben Harush
  • 833
  • 9
  • 26
1
vote
1 answer

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> llstPairs() { // sortedArrayGenerator is…
rima.j
  • 31
  • 2
1
vote
1 answer

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 statusReturnedFromApplyingRule() @Property …
Vijay
  • 595
  • 1
  • 13
  • 27
1
2