You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@RunWith(Theories.class)
public static class DoesntUseParams {
@DataPoint
public static int ONE = 1;
@Theory
public void everythingIsZero(int x, int y) {
assertThat(2, is(3));
}
}
@Test
public void reportBadParams() throws Exception {
assertThat(testResult(DoesntUseParams.class),
hasSingleFailureContaining("everythingIsZero(\"1\" <from ONE>, \"1\" <from ONE>)"));
}
The test is called "reportBadParams", which I guess is talking about the fact that the theory method everythingIsZero is not using the params x and y.
But it's not asserting anything about that specific fact.
Actually Theories doesn't seem to have any validation logic like that at all.
If you run the class DoesntUseParams, the theory fails with Caused by: java.lang.AssertionError: Expected: is <3> but: was <2>
org.junit.experimental.theories.internal.ParameterizedAssertionError: everythingIsZero("1" <from ONE>, "1" <from ONE>)
at org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:288)
at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:237)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:260)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:204)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:212)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:202)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:212)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:202)
at org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:187)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:88)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:58)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
Caused by: java.lang.AssertionError:
Expected: is <3>
but: was <2>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:960)
at org.junit.Assert.assertThat(Assert.java:925)
at org.junit.tests.experimental.theories.runner.UnsuccessfulWithDataPointFields$DoesntUseParams.everythingIsZero(UnsuccessfulWithDataPointFields.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:52)
at org.junit.experimental.theories.Theories$TheoryAnchor$2.evaluate(Theories.java:274)
at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:232)
... 21 more
The text was updated successfully, but these errors were encountered:
https://github.com/junit-team/junit4/blob/master/src/test/java/org/junit/tests/experimental/theories/runner/UnsuccessfulWithDataPointFields.java#L63
The test is called "reportBadParams", which I guess is talking about the fact that the theory method
everythingIsZero
is not using the paramsx
andy
.But it's not asserting anything about that specific fact.
Actually Theories doesn't seem to have any validation logic like that at all.
If you run the class DoesntUseParams, the theory fails with
Caused by: java.lang.AssertionError: Expected: is <3> but: was <2>
The text was updated successfully, but these errors were encountered: