Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameterization in UIAutomator/Espresso

I am using Android-UiAutomator / Espresso for automating Android app. For web automation i used selenium and for data parameterization used excel sheet and used Apache POI jars to read data.

i just want to know is there any way we can use the excel sheet or can implement data parameterization in Android-UiAutomator/ Espresso ? Right now i am using Spoon framework for reports and execution. Is there any feasibility in spoon framework for this feature.

Appreciate your response.

like image 440
user2350138 Avatar asked Jul 29 '26 07:07

user2350138


1 Answers

There isn't an out-of-the-box solution to import data from excel, but you can create parameterized tests using JUnit4.

The Parameterized runner allows you to do this. For example:

@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));
    }
}
like image 90
Allen Hair Avatar answered Jul 31 '26 21:07

Allen Hair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!