【问题标题】:Parameterization in UIAutomator/EspressoUIAutomator/Espresso 中的参数化
【发布时间】:2016-08-19 14:05:19
【问题描述】:

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

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

感谢您的回复。

【问题讨论】:

    标签: android android-espresso parameterized android-uiautomator spoon


    【解决方案1】:

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

    Parameterized 运行器允许您执行此操作。例如:

    @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));
        }
    }
    

    【讨论】:

    • 我在 excel 中有大约 100 条数据记录。我可以做这个概念吗
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-15
    • 2020-09-15
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    相关资源
    最近更新 更多