我使用Android- uiautomator/Espresso自动化Android应用程序。对于web自动化,我使用selenium和数据参数化使用excel表格,并使用Apache POI jar读取数据。
我只是想知道是否有任何方法我们可以使用excel表或可以在Android-UiAutomator/Espresso实现数据参数化?现在我正在使用Spoon框架进行报告和执行。在spoon框架中是否有实现此功能的可行性?
感谢您的回复。
没有从excel导入数据的现成解决方案,但是您可以使用JUnit4创建参数化测试。
Parameterized runner允许您这样做。例如:
@RunWith(Parameterized.class)
public class MyParameterizedTest {
@Parameter
public String mTextToFind;
private UiDevice mDevice;
@Parameters
public static Iterable<? extends Object> data() {
return Arrays.asList("foo", "bar", "baz");
}
@Before
public void setUp() {
Instrumentation instr = InstrumentationRegistry.getInstrumentation();
mDevice = UiDevice.getInstance(instr);
}
@Test
public void testHasText() {
// Make sure the text is on the screen
Assert.assertTrue(mDevice.hasObject(By.text(mTextToFind));
}
}