2

有什么方法可以让我在机器人应用程序的机器人测试中使用不同的数据多次运行单个测试用例。就像参数化的联合测试一样。

public class UserTest extends
        ActivityInstrumentationTestCase2<MainActivity> {

public UserTest() {
        super(TestActivity.class);
    }       

    @Override
    public void setUp() throws Exception {
        // setUp() is run before a test case is started.

        // This is where the solo object is created.
        solo = new Solo(getInstrumentation(), getActivity());
    }

public void testUserData1() throws Exception {

        // UserBean
        Bean bean = setUp.get(0);
        dataTest(bean);

    }



    public void testUserData2() throws Exception {

        // UserBean
        Bean bean = setUp.get(1);
        dataTest(bean);

    }
public void dataTest(Bean bean) {
        Log.e("testAddNote userbean", bean.toString());

        // Login
        solo.enterText(0, bean.getUserName());
        solo.enterText(1, bean.getPassWord());
        solo.clickOnButton(0);
}

这是我目前运行测试用例的方式,有一种方法可以使用 setUp 元素作为参数多次执行 dataTest(Bean)。意味着我必须使用不同的参数多次调用单个方法。

4

1 回答 1

2

我只是注意到,这仅在您使用https://code.google.com/p/zohhak/时才有效

在这种情况下,您可以这样做:

@TestWith({ 
           “2,  true”, 
           “6,  false”,
           “19, true” 
})
public void testPrimeNumberValidator(int number, boolean isPrime) { 
assertThat(… 
}
于 2013-04-15T16:08:45.137 回答