3

我正在使用 Android-UiAutomator / Espresso 来自动化 Android 应用程序。对于网络自动化,我使用了 selenium,对于数据参数化,我使用了 excel 表并使用 Apache POI jars 来读取数据。

我只想知道有什么方法可以使用 excel 表或可以在 Android-UiAutomator/Espresso 中实现数据参数化?现在我正在使用 Spoon 框架进行报告和执行。勺子框架是否有此功能的可行性。

感谢您的回复。

4

1 回答 1

1

从 excel 导入数据没有开箱即用的解决方案,但您可以使用 JUnit4 创建参数化测试。

参数化运行器允许您执行此操作。例如:

@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));
    }
}
于 2016-08-24T03:26:25.417 回答