Issue
I want to run UI tests for Android app with some predefined data which will vary depending on the test case. In iOS, it's possible to pass arguments to the tested app like this:
app = XCUIApplication()
app.reset()
app.launchArguments += ["--myArgument"]
app.launch()
These arguments are later available inside the app process.
Is there something similar for Android UI testing? Best way would to access these arguments via intent's extras.
getIntent().getExtras().getString(key)
Thanks for help!
Solution
Well, it turned out it's quite simple to simulate launch arguments with Intents
. In Android UI tests when using ActivityTestRule
it's possible to start an activity with a specific Intent
.
@Rule
public ActivityTestRule<MainActivity> activityRule
= new ActivityTestRule<>(MainActivity.class, false, false);
Intent i = new Intent();
i.putExtra("specificArgument", argumentValue);
activityRule.launchActivity(i);
Answered By - Kacper Dziubek
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.