问题描述
我正在使用参数编写一个 junit 测试用例。
输入是一个 int 数组,输出是 int 。方法是什么? 你能回复这里的答案吗?
@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,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));
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)