@DataPoints public static final Integer[] input1={1,2};
@Theory
@Test
public void test1(int input1){
}
@DataPoints public static final Integer[] input2={3,4};
@Theory
@Test
public void test2(int input2 ){
}
I want that test1 runs with data set input1 – {1,2} and test2 runs with input2 – {3,4}. But currently each test runs with both the data sets {1,2,3,4}. How to bind specific @DataPoints to specific @Theorys
DataPoints apply to the class. If you have a @Theory method which takes an int, and you have a DataPoint which is an array of ints, then it will be called with the int.
This calls test1 with 45 & 46, and test2 with 45 & 46. It calls testString1 with “foobar” and “barbar” and testString2 with “foobar” and “barbar”.
If you really want to use different data sets for different theories, you can wrap the data in a private class:
This calls test1 with 45 and test2 with 46. This works, but in my opinion, it obscures the code, and it may be a better solution to just split the Test class into two classes.