All Projects → sebaslogen → Cleanguitestarchitecture

sebaslogen / Cleanguitestarchitecture

Licence: mit
Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Cleanguitestarchitecture

AndroidTestingBox
Android project to experiment various testing tools
Stars: ✭ 63 (-54.68%)
Mutual labels:  cucumber, espresso
Green Coffee
Android library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests.
Stars: ✭ 219 (+57.55%)
Mutual labels:  cucumber, espresso
Newspaper
An aggregated newspaper app containing news from 10+ local news publishers in Hong Kong. Made with ❤
Stars: ✭ 82 (-41.01%)
Mutual labels:  espresso
Offlinefirstreactiveapp Tutorial
Check out the blog post for more info
Stars: ✭ 120 (-13.67%)
Mutual labels:  espresso
Kappuccino
A kotlin library to simplify how to do espresso tests on Android.
Stars: ✭ 104 (-25.18%)
Mutual labels:  espresso
Ruby Tools.el
Collection of handy functions for Emacs ruby-mode
Stars: ✭ 90 (-35.25%)
Mutual labels:  cucumber
Kotlin Espresso Sample
MVP Android project that uses Espresso instrumentation tests and Robolectric. All written in Kotlin.
Stars: ✭ 104 (-25.18%)
Mutual labels:  espresso
Gradle Cucumber Plugin
Plugin to support cucumber-jvm in Gradle builds
Stars: ✭ 80 (-42.45%)
Mutual labels:  cucumber
Spreewald
Our collection of useful cucumber steps.
Stars: ✭ 131 (-5.76%)
Mutual labels:  cucumber
Cabbage
Story BDD tool for executing elixir in ExUnit
Stars: ✭ 102 (-26.62%)
Mutual labels:  cucumber
Android Livedata Viewmodel
Android app that demonstrates how to use new Architecture components.
Stars: ✭ 114 (-17.99%)
Mutual labels:  espresso
Barista
☕️ The one who serves a great Espresso
Stars: ✭ 1,351 (+871.94%)
Mutual labels:  espresso
Mvpandroid
Sample app to demonstrate MVP (Model - View - Presenter) architecture in android
Stars: ✭ 91 (-34.53%)
Mutual labels:  espresso
Adbserver
Adb Server for Espresso tests
Stars: ✭ 105 (-24.46%)
Mutual labels:  espresso
Godog
Cucumber for golang
Stars: ✭ 1,287 (+825.9%)
Mutual labels:  cucumber
Salad
A nice mix of great BDD ingredients
Stars: ✭ 122 (-12.23%)
Mutual labels:  cucumber
Spring Boot Sample App
Sample app generated from my spring boot archtype on :https://github.com/Romeh/spring-boot-quickstart-archtype
Stars: ✭ 81 (-41.73%)
Mutual labels:  cucumber
Cukes
Cucumber DSL for testing RESTful Web Services
Stars: ✭ 95 (-31.65%)
Mutual labels:  cucumber
Seleniumwithcucucumber
In this project we will discuss working Selenium with cucumber
Stars: ✭ 104 (-25.18%)
Mutual labels:  cucumber
Websiteone
A website for Agile Ventures
Stars: ✭ 132 (-5.04%)
Mutual labels:  cucumber

Build Status

Clean GUI Test Architecture

Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern

The evolution journey of Android GUI testing

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

Execute the project

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):

  • Hard coded tags in annotation @CucumberOptions inside CucumberTestCase.java
  • Use parameters in command line like ./gradlew connectedAndroidTest -Ptags="@login-scenarios,@kitkat"
  • In Android Studio, run connectedAndroidTest in the right Gradle tab and then edit the run configuration to add under the 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.

In a nutshell

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

Advanced scenarios

When the code of your application and tests mature enough you will be doing things like this:

  • A test step from a test scenario that can be reused across multiple tests:
    Given I login into premium account
  • The step definition describes a lot of steps that need to happen to perform the requested action:
@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.

License

This content is released under the MIT License: http://opensource.org/licenses/MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].