Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Green Coffee | 218 | 2 years ago | 1 | mit | Java | |||||
Android library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests. | ||||||||||
Cleanguitestarchitecture | 135 | 6 years ago | 5 | mit | Java | |||||
Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern | ||||||||||
Cucumberespressodemo | 99 | 5 years ago | mit | Java | ||||||
A sample project for Cucumber and Espresso in Android | ||||||||||
Androidtestingbox | 62 | 3 years ago | 2 | apache-2.0 | Java | |||||
Android project to experiment various testing tools | ||||||||||
Espresso Cucumber | 47 | 8 years ago | 1 | apache-2.0 | Java | |||||
Library to test Android applications using Espresso test framework with cucumber BDD language and Spoon screenshots | ||||||||||
Movies | 41 | 4 years ago | 3 | apache-2.0 | Java | |||||
Android BDD Espresso + Cucumber | ||||||||||
Android Cucumber Espresso | 12 | 7 years ago | Java | |||||||
A template project to demonstrate the usage of Cucumber along with Espresso for acceptance testing on Android. | ||||||||||
Android_espresso_cucumber | 1 | 7 years ago | Java | |||||||
Workshop Android Espresso with Cucumber jvm | ||||||||||
No Cucumber | 1 | 5 years ago | Kotlin | |||||||
A toolset for making your manager happy and staying sane at the same time |
Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern
The code in this repository serves as a support example of all the test solutions discussed in this published article:
https://medium.com/@sebaslogen/the-evolution-journey-of-android-gui-testing-f65005f7ced8
Open the project in Android Studio and select the gradle task 'connectedCheck'
Alternative, from the command line run gradlew connectedCheck
Cucumber supports filtering execution of test scenarios with tags (i.e. @login-scenarios). To filter by tags you have the following options (which can't be combined):
@CucumberOptions
inside CucumberTestCase.java
./gradlew connectedAndroidTest -Ptags="@login-scenarios,@kitkat"
Script parameters
something like -Ptags="@login-scenarios,@kitkat"
More information about how to use and combine Cucumber tags here.
Note: Make sure to connect a phone to the computer or start an emulator before running the tests.
The sample test code can be summarized in these three elements:
1- Feature file describing the test scenario in English:
@ScenarioId("MyApp-135") @login-scenarios
Scenario: User can login with valid user name and password
Given I see the login page
When I login with user name "Sebas" and password "passion"
Then I see the welcome page
And the title is "Welcome Sebas"
2- Java glue code to translate English to Java (this is a step definition):
@Given("^I see the login page$")
public void i_see_the_login_page() {
mCurrentPage = new LoginPage();
}
@When("^I login with user name \"(.+)\" and password \"(.+)\"$")
public void i_login_with_username_and_password(final String userName, final String password) {
mCurrentPage = mCurrentPage.is(LoginPage.class).doLogin(userName, password);
}
@Then("^I see the welcome page$")
public void i_see_the_welcome_page() {
mCurrentPage.is(WelcomePage.class);
}
@And("^the title is \"(.+)\"$")
public void the_title_is(final String title) {
mCurrentPage.is(WelcomePage.class).checkTitle(title);
}
3- Page Object class implementing the interactions between tests and tested application:
/**
* Perform the login and return the next Welcome page/view
* @param userName Name of the user to login
* @param password Password of the user to login
* @return Welcome page/view
*/
public WelcomePage doLogin(String userName, String password) {
onView(withId(R.id.username)).perform(typeText(userName));
onView(withId(R.id.password)).perform(typeText(password), closeSoftKeyboard());
onView(withId(R.id.login_button)).perform(click());
return new WelcomePage();
}
When the code of your application and tests mature enough you will be doing things like this:
Given I login into premium account
@Given("^I login into premium account$")
public void i_log_in_to_premium() {
mCurrentPage = mCurrentPage
.is(MainPage.class).openMenu()
.is(MenuPage.class).selectMenuItem("Accounts")
.is(AccountsPage.class).selectNewAccountLogin()
.is(LoginPage.class).doLogin()
.is(AgreementPage.class).agreeToPrivacyInformation();
}
This step definition still hides most of the implementation details inside the Page Objects that contain the actual how-to communicate with the tested application.
This content is released under the MIT License: http://opensource.org/licenses/MIT