Update README.md

This commit is contained in:
2023-02-27 18:19:14 +00:00
committed by GitHub
parent 934767693a
commit afac9bfade

View File

@@ -1,5 +1,4 @@
# sumtest
====================
This project is running Android instrumtation tests in a BDD format with the help of android espresso and Cucumber BDD.
Cucumber is BDD framework which works for BDD.
@@ -15,10 +14,12 @@ Install Plugin: Android Studio > Preferences > Plugins > Search "Gherkin" > Inst
## Running the tests
There are three ways to run the test, either with Gradle or directly with adb.
There are two ways to run the test, either with Gradle or directly with adb.
- `Using an Android Studio IDE`- it is simplest way.
- `gradlew`- can be run from the command line
**Tests cannot be run from .feature file directly - android-cucumber has its limitations**
To run the test using `Android Studio IDE`:
Create a test run configuration:
@@ -33,3 +34,69 @@ To run the test using `Android Studio IDE`:
To run the test using `gradlew`:
./gradlew connectedCheck
## Reports
There are two generated reports
- `Using an Android Studio IDE`- it is simplest way.
- `gradlew`- can be run from the command line
## An example
The app performs a very basic addition operation and displays the result to the user. The user enter will 2 integer values into the available text fields and after tapping the button either the result of the operation, or an error message will be displayed. The operation in the app may take a few seconds to complete, and while it is in progress a loading indicator will be shown.
* the user must be able to perform a cum on the calculator.
This translates to the following **Gherkin** syntax, which could be even written by the customer or project lead.
**sumtest.feature:**
```gherkin
@calculator_test
Scenario Outline: Run successful functions on the calculator
Given I start the application
When I run calculator sum for values "<First value>" and "<Second value>"
And I assert the operation has run successfully with result "<Sum>"
Examples:
| First value | Second value | Sum |
| 5 | 5 | 10 |
| -231 | -5 | -236 |
| 999 | 1 | 1000 |
| 1000 | 1000 | 2000 |
| -1000 | -1000 | -2000 |
```
Simple and can easily be read and understood by non-programmers!
From that file, Cucumber pretty much autogenerates the Regular Expressions and Annotations needed to match the specific criterias. Then we only need to add the test logic and if we want, modify the method names.
**SumTestSteps.java (annotations and methods auto-generated):**
```kotlin
class SumTestSteps {
....
@Given("I start the application")
fun i_start_the_application() {
mActivityScenarioRule.moveToState(RESUMED)
}
@When("^I run calculator sum for values \"([^\"]*)\" and \"([^\"]*)\"$")
fun i_run_calculator_sum_for_values(firstValue: String, secondValue: String) {
sumTest {
submitValuesForSum(firstValue, secondValue)
}
}
@And("^I assert the operation has run successfully with result \"([^\"]*)\"\$")
fun i_assert_the_operation_has_run_successfully(result: String) {
sumTest {
checkSumHasCalculated(result)
}
}
....
}
```