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

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

Open
awturner opened this issue Feb 7, 2020 · 2 comments · May be fixed by #1651
Open

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

awturner opened this issue Feb 7, 2020 · 2 comments · May be fixed by #1651

Comments

@awturner
Copy link

awturner commented Feb 7, 2020

@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 added a commit to awturner/junit4 that referenced this issue Feb 11, 2020
…re is no @FromDataPoints annotation, or the named data points represent a non-empty set of the same type.

Fixes junit-team#1648
@awturner
Copy link
Author

awturner commented Mar 2, 2020

Ping?

@marcphilipp marcphilipp added this to the 4.13.1 milestone Apr 19, 2020
@marcphilipp marcphilipp removed this from the 4.13.1 milestone Oct 11, 2020
@VivekShahare04
Copy link

To ensure that the @FromDataPoints annotation correctly enforces that data points are used as specified and raises an error if there are no matching data points, you can use JUnit's Assume class. This will help ensure that if the specific data points are not provided, the tests will fail with a clear message. @awturner

1.import org.junit.Assume;
2.Use Assume.assumeTrue to check if the data points are available before running the tests.

@awturner could you assign me this i'll just try to bebug it?

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

Successfully merging a pull request may close this issue.

5 participants
@marcphilipp @stefanbirkner @awturner @VivekShahare04 and others