我目前正在使用junit和robotium进行黑盒测试(随机测试)。我在将数据传递给测试方法时遇到问题。2个文件,一个是getData.java
(从文本文件中读取测试用例并转换为数组),另一个是testMain.java
(测试android应用程序的测试方法)。
如果测试方法有参数,另一个问题是无法运行 junit 测试。
此代码是可执行的
public void testDisplayBlackBox() {
//Enter 10 in first editfield
solo.enterText(0, data1);
//Enter 20 in first editfiel
solo.enterText(1, "3");
//Click on Multiply button
solo.clickOnButton("Multiply");
//Verify that resultant of 10 x 20
assertTrue(solo.searchText("0"));
}
但是如果传递和参数以获取数据,则会发生错误,junit 将跳过此方法
public void testDisplayBlackBox(string a) {
string b =a[0];
//Enter 10 in first editfield
solo.enterText(0, b);
//Enter 20 in first editfiel
solo.enterText(1, "3");
//Click on Multiply button
solo.clickOnButton("Multiply");
//Verify that resultant of 10 x 20
assertTrue(solo.searchText("0"));
}