mardi 4 août 2015

ParameterizedAssertionError in JUnit Theory

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.

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 ParameterizedAssertionError

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) ...

I used an example from here ParameterizedAssertionError in Theory but facing exactly the same. It's fixed but I'm not using the same .jar. Is there any other fix to resolve this?

Aucun commentaire:

Enregistrer un commentaire