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

No error/warning on non static method annotated with @DataPoint #125

Closed
jschneider opened this issue Jul 28, 2010 · 5 comments · Fixed by #623
Closed

No error/warning on non static method annotated with @DataPoint #125

jschneider opened this issue Jul 28, 2010 · 5 comments · Fixed by #623

Comments

@jschneider
Copy link

This test is marked as successfull but did not run:

 @RunWith( Theories.class )
 public class TheoriesTest {
  @Theory
  public void aTheory( String arg ) {
    System.out.println( "TheoriesTest.aTheory(" + arg + ")" );
    assertNotNull( arg );
  }

  @DataPoint
  public String getParam() {
    return "daParam";
  }
 }

I think the problem lies in Theories:126.
statement.evaluate() catches exceptions silently
(org.junit.experimental.theories.Theories.TheoryAnchor#methodCompletesWithParameters:158).

Therefore "handleDataPointSuccess" is called even when an exception has
been thrown....

So I think there are at least two things missing:

  • Proper exception handling...
  • Checking the DataPoint(s) methods for the static keyword
@MatrixFrog
Copy link

@MatrixFrog
Copy link

I have a test case and proposed fix at https://github.com/MatrixFrog/junit/tree/dataPoints -- I suppose I could throw a more JUnit-specific exception, rather than just RuntimeException, but I don't know what that would be.

@MatrixFrog
Copy link

Now packaged up as a shiny pull request: https://github.com/KentBeck/junit/pull/328

@marcphilipp
Copy link
Member

Linking to #328.

pimterry added a commit to pimterry/junit that referenced this issue Jan 28, 2013
dsaff referenced this issue Jan 29, 2013
…-#125

Added validation that all datapoint methods and fields are public and static to theory initialization
@marcphilipp
Copy link
Member

Closed #125 as it has been fixed by #623.

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