junit4 icon indicating copy to clipboard operation
junit4 copied to clipboard

`@FromDataPoints("misspelled") EnumType` shouldn't test all enum values

Open awturner opened this issue 5 years ago • 2 comments

@RunWith(Theories.class)
public class NonExistentTheory {
  @DataPoints("foo")
  public static final ImmutableSet<MetaSyntacticVariable> FOOS =
      ImmutableSet.of(MetaSyntacticVariable.FOO);

  @Theory
  public void doWithTheFoo(@FromDataPoints("bar") MetaSyntacticVariable whatever) {
    System.err.println(whatever);
  }

  @Theory
  public void doWithTheBoolean(@FromDataPoints("bar") boolean whatever) {
    System.err.println(whatever);
  }

  enum MetaSyntacticVariable {
    FOO, BAR, BAZ
  }
}

It is surprising that these @FromDataPoints-annotated parameters receive the same values as if the annotation were omitted. This means that typos in data point names aren't flagged as errors.

If the @FromDataPoints is present, and nothing matches, it would be helpful to raise "Never found parameters that satisfied method assumptions.".

awturner avatar Feb 07 '20 14:02 awturner

Ping?

awturner avatar Mar 02 '20 23:03 awturner