Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
daniel-huss opened this issue Sep 11, 2023 · 4 comments
Labels

Comments

@daniel-huss
Copy link

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.

@jlink
Copy link
Collaborator

jlink commented Sep 11, 2023

@daniel-huss Thanks for creating the issue. Looks like a bug at first glance. I'll check later this week.

@jlink
Copy link
Collaborator

jlink commented Sep 30, 2023

@daniel-huss Sorry for the delay. It's a bug. Working on it right now.

jlink added a commit that referenced this issue Sep 30, 2023
@jlink
Copy link
Collaborator

jlink commented Sep 30, 2023

Fixed and released in 1.8.0-SNAPSHOT

@jlink jlink closed this as completed Sep 30, 2023
@jlink jlink removed the in progress label Sep 30, 2023
@jlink
Copy link
Collaborator

jlink commented Oct 20, 2023

1.8.1 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants