Java – JUnit tests the hypothesis of theoretical failure

I'm implementing a JUnit test (version 4.11) that will run several times with different parameters So I use the JUnit theory class This is how I implement testing:

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 calling dotest () The error message is:

I don't define any assumptions. According to this Oracle example, it's not necessary to define a hypothesis

What did I miss?

Solution

Fwiw I think this is because the parameters of dotest () do not match the parameters you defined in @ datapoints - the 3D array of GetData () and the two 1D arrays of dotest ()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>