pholser/junit-quickcheck

Add "exhaustive" mode to Property

Closed this issue · 4 comments

Admit a mode attribute on Property:

enum Mode { SAMPLING, EXHAUSTIVE }

@interface Property {
    // ...

    Mode mode() default SAMPLING;
}

enum Response { YES, NO, UNSURE }

@Property(trials = 45)
public void sampling(
    int arg0,
    boolean arg1,
    Response arg2,
    @Only({"1", "2", "0", "-1"}) int arg3) {

    /*
    Invoked 45 times.
    45 tuples (arg0, arg1, arg2, arg3) generated.
    Each value of each tuple chosen at random from its domain.
    Domain of arg3 narrowed by @Only.
    */
}

@Property(trials = 77, mode = EXHAUSTIVE)
public void exhaustive(
    int arg0,
    boolean arg1,
    Response arg2,
    @Only({"1", "2", "0", "-1"}) int arg3) {

    /*
    Invoked 77 * 2 * 3 * 4 times --
    once for each choice of 77 randomly chosen arg0,
    two possible values of arg1, three possible values of arg2,
    and four possible values of arg2.
    */
}

I am considering splitting this issue. The "exhaustive" vs. "sampling" stuff is basically done and vetted -- might be useful to merge that into master and not hold it up while I address the @Only/@Also bits.

This issue is becoming as follows:

Admit a mode attribute on Property:

enum Mode { SAMPLING, EXHAUSTIVE }

@interface Property {
    // ...

    Mode mode() default SAMPLING;
}

@Property(trials = 45)
public void sampling(int arg0, int arg1) {

    /*
    Invoked 45 times.
    45 tuples (arg0, arg1) generated.
    Each value of each tuple chosen at random from its domain.
    */
}

@Property(trials = 77, mode = EXHAUSTIVE)
public void exhaustive(int arg0, int arg1) {
    /*
    Invoked 77 * 77 times --
    once for each choice of 77 randomly chosen arg0,
    and 77 randomly chosen arg1.
    */
}

@Only and @Also will be added as part of #164.

In 0.8 alpha 7.