mercredi 4 mai 2016

JUnit test Theory fails assumption

I am implementing a JUnit test (version 4.11) which will run several times with different parameters. Therefor I use JUnit Theory class. This is how I implemented the test:

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

@RunWith(Theories.class)
public class MyTest {

static double[][][] arrayData;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    double[] date_1 = {1, 2, 3};
    double[] expect_1 = {2, 4, 6};

    double[] date_2 = {10, 20, 30};
    double[] expect_2 = {20, 40, 60};

    arrayData = new double[][][] {
        {date_1, expect_1},
        {date_2, expect_2}
    };

    return;
}

@DataPoints
public static double[][][] getData() {
    return arrayData;
}

@Theory
public void doTest(double[] data, double[] expect) {
    // do some testing
    return;
}

}

Whenever I run it the test fails before it even calls doTest(). The error message is:

java.lang.AssertionError: Never found parameters that satisfied method assumptions. Violated assumptions: [ ]

I did not define any assumptions and according to this oracle example it is not necessary to define an assumption.

What am I missing?

Aucun commentaire:

Enregistrer un commentaire