KentBeck/junit — Issue #379: ParameterizedAssertionError in Theory
Author: NicoleRauch
Created: 2012-02-12 19:43:04+00:00
State: open

The following test throws a ParameterizedAssertionError.
It seems that both parameters of the test method get the same argument, although they are of different types.

```java

import java.lang.reflect.Field;
import java.util.ResourceBundle;

import org.junit.experimental.theories.DataPoint;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;

@RunWith(Theories.class)
public class ErrorIDsTest {

@DataPoints
public static Field[] errorIDs() {
return ErrorIDs.class.getDeclaredFields();
}

@DataPoint
public static ResourceBundle bundle = null;

@Theory
public void testThatFails(Field field, ResourceBundle bundle) throws Exception {
}
}

interface ErrorIDs {
public final String Fehler = "ErrorIDs.Fehler";
}
```

The exception is

org.junit.experimental.theories.internal.ParameterizedAssertionError: testThatFails(errorIDs[0], errorIDs[0])
at org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:183)
at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:138)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:119)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:103)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:112)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:101)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:112)
at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:101)
at org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:89)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.experimental.theories.Theories$TheoryAnchor$2.evaluate(Theories.java:167)
at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:133)
... 22 more