All Projects → mauriciotogneri → Green Coffee

mauriciotogneri / Green Coffee

Licence: mit
Android library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Green Coffee

Behat
BDD in PHP
Stars: ✭ 3,696 (+1587.67%)
Mutual labels:  gherkin, cucumber
Device Automator
An easy to use, Espresso like, syntax on top of the Android UI Automator testing framework
Stars: ✭ 63 (-71.23%)
Mutual labels:  espresso, ui-testing
Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+2410.05%)
Mutual labels:  gherkin, cucumber
Compose
Nice and simple DSL for Espresso Compose UI testing in Kotlin
Stars: ✭ 56 (-74.43%)
Mutual labels:  espresso, ui-testing
Cleanguitestarchitecture
Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern
Stars: ✭ 139 (-36.53%)
Mutual labels:  cucumber, espresso
espresso-robot-pattern-sample
Espresso Robot Pattern Sample with Spoon Integration
Stars: ✭ 37 (-83.11%)
Mutual labels:  espresso, ui-testing
Kakao
Nice and simple DSL for Espresso in Kotlin
Stars: ✭ 1,109 (+406.39%)
Mutual labels:  espresso, ui-testing
AndroidTestingBox
Android project to experiment various testing tools
Stars: ✭ 63 (-71.23%)
Mutual labels:  cucumber, espresso
Cabbage
Story BDD tool for executing elixir in ExUnit
Stars: ✭ 102 (-53.42%)
Mutual labels:  gherkin, cucumber
Godog
Cucumber for golang
Stars: ✭ 1,287 (+487.67%)
Mutual labels:  gherkin, cucumber
flutter gherkin
A Gherkin parsers and runner for Dart and Flutter which is very similar to cucumber
Stars: ✭ 160 (-26.94%)
Mutual labels:  gherkin, cucumber
Gunit
GUnit - Google.Test/Google.Mock/Cucumber on steroids
Stars: ✭ 156 (-28.77%)
Mutual labels:  gherkin, cucumber
gherkin
Pure Rust implementation of Gherkin language (`.feature` file) for Cucumber testing framework.
Stars: ✭ 41 (-81.28%)
Mutual labels:  gherkin, cucumber
bat
Gherkin based DSL for testing HTTP APIs via Cucumber.JS
Stars: ✭ 30 (-86.3%)
Mutual labels:  gherkin, cucumber
sonar-gherkin-plugin
SonarQube Cucumber Gherkin Analyzer
Stars: ✭ 33 (-84.93%)
Mutual labels:  gherkin, cucumber
Cuke linter
A linting tool for Cucumber
Stars: ✭ 24 (-89.04%)
Mutual labels:  gherkin, cucumber
CucumberSwift
A lightweight swift Cucumber implementation
Stars: ✭ 40 (-81.74%)
Mutual labels:  gherkin, cucumber
cucumber-react
React components for Cucumber
Stars: ✭ 15 (-93.15%)
Mutual labels:  gherkin, cucumber
Katasuperheroeskotlin
Super Heroes Kata for Android Developers in Kotlin. The main goal is to practice UI Testing.
Stars: ✭ 77 (-64.84%)
Mutual labels:  espresso, ui-testing
Radish
Behavior Driven Development tooling for Python. The root from red to green.
Stars: ✭ 153 (-30.14%)
Mutual labels:  gherkin, cucumber

License Android Arsenal

Green Coffee

Green Coffee is a library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests using the step definitions that you declare. Visit the wiki for more detailed information.

Example

Given the following feature:

Feature: Login screen to authenticate users

	Scenario: Invalid username and password
        Given I see an empty login form
         When I introduce an invalid username
          And I introduce an invalid password
          And I press the login button
         Then I see an error message saying 'Invalid credentials'

First, create a class that extends from GreenCoffeeTest and declare the Activity, the feature and the step definitions that will be used:

@RunWith(Parameterized.class)
public class LoginFeatureTest extends GreenCoffeeTest
{
    @Rule
    public ActivityTestRule<LoginActivity> activity = new ActivityTestRule<>(LoginActivity.class);

    public LoginFeatureTest(ScenarioConfig scenarioConfig)
    {
        super(scenarioConfig);
    }

    @Parameters(name = "{0}")
    public static Iterable<ScenarioConfig> scenarios() throws IOException
    {
        return new GreenCoffeeConfig()
                        .withFeatureFromAssets("assets/login.feature")
                        .takeScreenshotOnFail()
                        .scenarios(
                            new Locale("en", "GB"),
                            new Locale("es", "ES")
                        ); // the locales used to run the scenarios (optional)
    }

    @Test
    public void test()
    {
        start(new LoginSteps());
    }
}

Next, create a class containing the steps definitions:

public class LoginSteps extends GreenCoffeeSteps
{
    @Given("^I see an empty login form$")
    public void iSeeAnEmptyLoginForm()
    {
        onViewWithId(R.id.login_input_username).isEmpty();
        onViewWithId(R.id.login_input_password).isEmpty();
    }

    @When("^I introduce an invalid username$")
    public void iIntroduceAnInvalidUsername()
    {
        onViewWithId(R.id.login_input_username).type("guest");
    }

    @When("^I introduce an invalid password$")
    public void iIntroduceAnInvalidPassword()
    {
        onViewWithId(R.id.login_input_password).type("1234");
    }

    @When("^I press the login button$")
    public void iPressTheLoginButton()
    {
        onViewWithId(R.id.login_button_doLogin).click();
    }

    @Then("^I see an error message saying 'Invalid credentials'$")
    public void iSeeAnErrorMessageSayingInvalidCredentials()
    {
        onViewWithText(R.string.login_credentials_error).isDisplayed();
    }
}

And that's it, now you can create your own tests using Green Coffee. This is how it looks when you run a more complex test:

Example

You can see an example applied to a full app here.

Installation

Add the following code to your root build.gradle:

allprojects
{
    repositories
    {
        maven
        {
            url 'https://jitpack.io'
        }
    }
}

Add the following code to your module build.gradle file:

dependencies
{
    androidTestImplementation 'androidx.test🏃1.3.0'
    androidTestImplementation 'androidx.test:rules:1.3.0'
    androidTestImplementation 'com.github.mauriciotogneri:green-coffee:3.6.0'
}

And the following test instrumentation runner:

defaultConfig
{
    testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
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].