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 | 4 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 |
Cucumber is BDD framework which works for iOS, Android and more. For Android, we are going to use cucumber-jvm, java port of cucumber.
BDD's behavior text is written in a business-readable domain-specific language.
It aims to communicate better between non-tech to tech over Software trueness and quality.
The readable behavior also serves as documentation.
Gherkin plugin works with Android Studio 2.0. Manual translation is still required but .feature file has pretty syntax highlighting and any invalid cucumber syntax will be flagged with an error.
Install Plugin: Android Studio > Preferences > Plugins > Search "Gherkin" > Install & Restart Android Studio
Add dependencies
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestCompile 'com.android.support:support-annotations:26.1.0' // <-- match with the support lib version
androidTestCompile 'info.cukes:cucumber-android:[email protected]'
androidTestCompile 'info.cukes:cucumber-picocontainer:1.2.4'
Create custom instrumentation runner under androidTest package
public class Instrumentation extends MonitoringInstrumentation {
private final CucumberInstrumentationCore mInstrumentationCore = new CucumberInstrumentationCore(this);
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
mInstrumentationCore.create(arguments);
start();
}
@Override
public void onStart() {
super.onStart();
waitForIdleSync();
mInstrumentationCore.start();
}
}
Application ID / Runner setup in app/build.gradle. Make sure this matches with the package name of the test.
testApplicationId "com.emmasuzuki.cucumberespressodemo.test"
testInstrumentationRunner "com.emmasuzuki.cucumberespressodemo.test.Instrumentation"
Create assets/features directory under androidTest. This directory holds behavior(.feature) files.
Set assets directory in app/build.gradle.
android {
...
sourceSets {
androidTest {
assets.srcDirs = ['src/androidTest/assets']
}
}
}
Make a file, login.feature, and put under src/androidTest/assets/features.
Feature: Login
Perform login on email and password are inputted
Scenario Outline: Input email and password in correct format
Given I have a LoginActivity
When I input email <email>
And I input password "<password>"
And I press submit button
Then I should <see> auth error
Examples:
| email | password | see |
| [email protected] | bananacake | true |
| [email protected] | lemoncake | false | <-- valid email and password
| [email protected] | lemoncake | true |
EX) "Given I have a LoginActivity" in behavior translates to
@Given("^I have a LoginActivity")
public void I_have_a_LoginActivity(){}
in step definition.
"Then I should see error on the
@Then("^I should see error on the (\\S+)$")
public void I_should_see_error_on_the_editTextView(final String viewName) {}
@When("^I input email (\\S+)$")
public void I_input_email(final String email) {
onView(withId(R.id.email)).perform(typeText(email));
}
@Then("^I should (true|false) auth error$")
public void I_should_see_auth_error(boolean shouldSeeError) {
if (shouldSeeError) {
onView(withId(R.id.error)).check(matches(isDisplayed()));
} else {
onView(withId(R.id.error)).check(matches(not(isDisplayed())));
}
}
On command line, run with $./gradlew connectedCheck
On Android Studio, take the following steps:
Write code and run test again. Observe the tests pass.