I am writing a junit test case using parameters.
the input is an int array and output is int . What would be the method ?
Can you please reply what would be the answer here ?
@RunWith(Parameterized.class)
public class TestingJunitClassTest {
TestingJunitClass testJunitObject;
private int[] input;
private int expectedOutput;
public TestingJunitClassTest(int[] input, int expectedOutput) {
this.input = input;
this.expectedOutput = expectedOutput;
}
@Before
public void init() {
System.out.println("Running before every test");
testJunitObject = new TestingJunitClass();
}
@Parameters
public static List<Object[][]> testConditions() {
return Arrays.asList(new Object[][] {{{4,8,7,0,3},8},{{10,25,35,4},35}}); //gives error Type mismatch: cannot convert from int[] to Object
}
@Test
public void testGetMaxNumbersForPositiveIntegers() {
assertEquals(expectedOutput, testJunitObject.getMaxNumber(input));
}
question from:
https://stackoverflow.com/questions/65651021/how-can-i-define-int-as-input-and-int-as-expected-for-parameters-method-jun 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…