Skip to content

IllegalArgumentException: "At least one shrinkable is required" during shrinking hides cause of test failure #522

Description

@daniel-huss

Testing Problem

Minimal(ish?) reproducer:

import net.jqwik.api.*;
import net.jqwik.api.domains.Domain;
import net.jqwik.api.domains.DomainContextBase;

import java.util.stream.Collectors;
import java.util.stream.IntStream;

@Domain(ExceptionDuringShrinkingTest.MyDomain.class)
class ExceptionDuringShrinkingTest {
    @Property
    void test(@ForAll NotRelevant obj) {
        throw new RuntimeException("Hello!");
    }

    public static class NotRelevant {
    }

    public static class MyDomain extends DomainContextBase {
        @Provide
        public static Arbitrary<NotRelevant> objects() {
            return Arbitraries.subsetOf(IntStream.range(0, 1000).boxed().collect(Collectors.toSet()))
                              .flatMap(subset -> Combinators
                                      .combine(subset.stream().map(Arbitraries::just).collect(Collectors.toList()))
                                      .as(ignored -> new NotRelevant())
                              );
        }
    }
}

When this test fails, I get

timestamp = 2023-09-11T09:50:23.088071, ExceptionDuringShrinkingTest:test = 
 java.util.concurrent.ExecutionException:
   java.lang.IllegalArgumentException: At least one shrinkable is required

but the RuntimeException that failed the test is not printed. To my best knowledge the above usage of flatMap / combine is technically valid - apologies if it's not.

Found using version 1.8.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions