Skip to content

Commit 8ce5d8e

Browse files
committed
Added Cukulator Android example test.
1 parent a42992d commit 8ce5d8e

24 files changed

+623
-47
lines changed

android/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ The generated target artifacts are an [apklib](https://code.google.com/p/maven-a
1414

1515
Integration-tests are in `examples/android/android-test/cucumber-test/`.
1616

17+
### Building
18+
`mvn package -pl android -am -P android`
19+
1720
### Debugging
18-
Please read [the Android documentation on debugging](https://developer.android.com/tools/debugging/index.html).
21+
Please read [the Android documentation on debugging](https://developer.android.com/tools/debugging/index.html).

examples/android/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ To *build* all android example modules with maven:
44

55
To *clean* all android example modules with maven:
66

7-
`mvn clean -pl examples/android -P android,android-examples`
7+
`mvn clean -pl examples/android -amd -P android,android-examples`

examples/android/android-test/README.md

-18
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,3 @@ Please read [the Android documentation on debugging](https://developer.android.c
2222
**Using Maven:**
2323

2424
`mvn install -pl examples/android/android-test -am -P android,android-examples`
25-
26-
**Using [adb](https://developer.android.com/tools/testing/testing_otheride.html#AMSyntax) on the commandline:**
27-
28-
`adb install -r examples/android/android-test/target/cucumber-android-test-*.apk`
29-
30-
`adb shell am instrument -w -r cucumber.android.test/cucumber.api.android.CucumberInstrumentation`
31-
32-
**Using Ant:**
33-
34-
Please read ["Testing from Other IDEs"](https://developer.android.com/tools/testing/testing_otheride.html).
35-
36-
`TODO: provide standard ant buildfile and custom script for dependency downloading`
37-
38-
**Using an IDE:**
39-
40-
[Set up your IDE](https://developer.android.com/sdk/installing/index.html) and import this directory as a
41-
new Android test-project. You will also need to create a new run-configuration with `CucumberInstrumentation`.
42-
Please also refer to ["Testing from Eclipse with ADT"](https://developer.android.com/tools/testing/testing_eclipse.html).
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
114
target=android-18
215
android.library=false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
*.class
3+
local.properties
4+
libs/*.jar
5+
.idea/
6+
bin/
7+
gen/
8+
out/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="cucumber.example.android.cukeulator.test"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<application>
8+
<uses-library android:name="android.test.runner"/>
9+
</application>
10+
<!--
11+
This declares that this application uses the instrumentation test runner targeting
12+
the package of cucumber.example.android.cukeulator. To run the tests use the command:
13+
"adb shell am instrument -w cucumber.example.android.cukeulator.test/cucumber.api.android.CucumberInstrumentation"
14+
-->
15+
<instrumentation
16+
android:name="cucumber.api.android.CucumberInstrumentation"
17+
android:targetPackage="cucumber.example.android.cukeulator"
18+
android:label="Tests for cucumber.example.android.cukeulator"/>
19+
</manifest>
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Cukeulator Example Test
2+
This is the example test-project for the Cukeulator app.
3+
4+
### Setup
5+
Features must be placed in `assets/features/`. Subdirectories are allowed.
6+
7+
Read `libs/README.md` for details on dependencies.
8+
9+
#### Using ant
10+
1. Please read ["Building and Running from the Command Line"](https://developer.android.com/tools/building/building-cmdline.html).
11+
2. Make sure you have the required jars in `libs/` (read libs/README.md).
12+
3. Run `ant test`.
13+
14+
#### Using an IDE
15+
1. Please read ["Building and Running from Eclipse with ADT"](https://developer.android.com/tools/building/building-eclipse.html).
16+
2. Create an Android test-project from these sources with `cucumber-example/` as the tested project.
17+
3. Create a run configuration with `cucumber.android.api.CucumberInstrumentation` as the instrumentation.
18+
4. Put the required jar dependencies into `libs/`.
19+
20+
### Using Maven
21+
To build:
22+
23+
`mvn package -pl examples/android/cukeulator-test -am -P android,android-examples`
24+
25+
To intall:
26+
27+
`mvn android:deploy-dependencies android:deploy -pl examples/android/cukeulator-test -P android-examples`
28+
29+
To run instrumentation:
30+
31+
`mvn android:instrument -pl examples/android/cukeulator-test -P android-examples`
32+
33+
View all available goals:
34+
35+
`mvn android:help -pl examples/android/cukeulator-test -P android-examples`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file is used to override default values used by the Ant build system.
2+
#
3+
# This file must be checked into Version Control Systems, as it is
4+
# integral to the build system of your project.
5+
6+
# This file is only used by the Ant script.
7+
8+
# You can use this to override default values such as
9+
# 'source.dir' for the location of your java source folder and
10+
# 'out.dir' for the location of your output folder.
11+
12+
# You can also use it define how the release builds are signed by declaring
13+
# the following properties:
14+
# 'key.store' for the location of your keystore and
15+
# 'key.alias' for the name of the key to use.
16+
# The password will be asked during the build when you use the 'release' target.
17+
18+
tested.project.dir=../cukeulator
19+
test.runner=cucumber.api.android.CucumberInstrumentation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: Calculate a result
2+
Perform an arithmetic operation on two numbers using a mathematical operator
3+
"""The purpose of this feature is to illustrate how existing step-definitions
4+
can be efficiently reused."""
5+
6+
Scenario Outline: Enter a digit, an operator and another digit
7+
Given I have a CalculatorActivity
8+
When I press <num1>
9+
And I press <op>
10+
And I press <num2>
11+
And I press =
12+
Then I should see <result> on the display
13+
14+
Examples:
15+
| num1 | num2 | op | result |
16+
| 9 | 8 | + | 17.0 |
17+
| 7 | 6 | – | 1.0 |
18+
| 5 | 4 | x | 20.0 |
19+
| 3 | 2 | / | 1.5 |
20+
| 1 | 0 | / | Infinity |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Feature: Add two numbers
2+
Calculate the sum of two numbers which consist of one or more digits
3+
4+
Scenario Outline: Enter one digit per number and press =
5+
Given I have a CalculatorActivity
6+
When I press <num1>
7+
And I press +
8+
And I press <num2>
9+
And I press =
10+
Then I should see <sum> on the display
11+
12+
Examples:
13+
| num1 | num2 | sum |
14+
| 0 | 0 | 0.0 |
15+
| 0 | 1 | 1.0 |
16+
| 1 | 1 | 2.0 |
17+
18+
Scenario Outline: Enter two digits per number and press =
19+
Given I have a CalculatorActivity
20+
When I press <num1>
21+
When I press <num2>
22+
And I press +
23+
And I press <num3>
24+
And I press <num4>
25+
And I press =
26+
Then I should see <sum> on the display
27+
28+
Examples:
29+
| num1 | num2 | num3 | num4 | sum |
30+
| 0 | 0 | 2 | 0 | 20.0 |
31+
| 9 | 8 | 7 | 6 | 174.0 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Feature: Divide two numbers
2+
Calculate the quotient of two numbers which consist of one or more digits
3+
4+
Scenario Outline: Enter one digit per number and press =
5+
Given I have a CalculatorActivity
6+
When I press <num1>
7+
And I press /
8+
And I press <num2>
9+
And I press =
10+
Then I should see <quotient> on the display
11+
12+
Examples:
13+
| num1 | num2 | quotient |
14+
| 0 | 0 | NaN |
15+
| 1 | 0 | Infinity |
16+
| 1 | 2 | 0.5 |
17+
18+
Scenario Outline: Enter two digits per number and press =
19+
Given I have a CalculatorActivity
20+
When I press <num1>
21+
When I press <num2>
22+
And I press /
23+
And I press <num3>
24+
And I press <num4>
25+
And I press =
26+
Then I should see <quotient> on the display
27+
28+
Examples:
29+
| num1 | num2 | num3 | num4 | quotient |
30+
| 2 | 2 | 2 | 2 | 1.0 |
31+
| 2 | 0 | 1 | 0 | 2.0 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Feature: Multiply two numbers
2+
Calculate the product of two numbers which consist of one or more digits
3+
4+
Scenario Outline: Enter one digit per number and press =
5+
Given I have a CalculatorActivity
6+
When I press <num1>
7+
And I press x
8+
And I press <num2>
9+
And I press =
10+
Then I should see <product> on the display
11+
12+
Examples:
13+
| num1 | num2 | product |
14+
| 0 | 0 | 0.0 |
15+
| 0 | 1 | 0.0 |
16+
| 1 | 2 | 2.0 |
17+
18+
Scenario Outline: Enter two digits per number and press =
19+
Given I have a CalculatorActivity
20+
When I press <num1>
21+
When I press <num2>
22+
And I press x
23+
And I press <num3>
24+
And I press <num4>
25+
And I press =
26+
Then I should see <product> on the display
27+
28+
Examples:
29+
| num1 | num2 | num3 | num4 | product |
30+
| 2 | 2 | 2 | 2 | 484.0 |
31+
| 2 | 0 | 1 | 0 | 200.0 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Feature: Subtract two numbers
2+
Calculate the difference of two numbers which consist of one or more digits
3+
4+
Scenario Outline: Enter one digit per number and press =
5+
Given I have a CalculatorActivity
6+
When I press <num1>
7+
And I press –
8+
And I press <num2>
9+
And I press =
10+
Then I should see <delta> on the display
11+
12+
Examples:
13+
| num1 | num2 | delta |
14+
| 0 | 0 | 0.0 |
15+
| 0 | 1 | -1.0 |
16+
| 1 | 2 | -1.0 |
17+
18+
Scenario Outline: Enter two digits per number and press =
19+
Given I have a CalculatorActivity
20+
When I press <num1>
21+
When I press <num2>
22+
And I press –
23+
And I press <num3>
24+
And I press <num4>
25+
And I press =
26+
Then I should see <delta> on the display
27+
28+
Examples:
29+
| num1 | num2 | num3 | num4 | delta |
30+
| 2 | 2 | 2 | 2 | 0.0 |
31+
| 2 | 0 | 1 | 0 | 10.0 |
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="AndroidCucumberExampleTest" default="help">
3+
4+
<!-- The local.properties file is created and updated by the 'android' tool.
5+
It contains the path to the SDK. It should *NOT* be checked into
6+
Version Control Systems. -->
7+
<property file="local.properties"/>
8+
9+
<!-- The ant.properties file can be created by you. It is only edited by the
10+
'android' tool to add properties to it.
11+
This is the place to change some Ant specific build properties.
12+
Here are some properties you may want to change/update:
13+
14+
source.dir
15+
The name of the source directory. Default is 'src'.
16+
out.dir
17+
The name of the output directory. Default is 'bin'.
18+
19+
For other overridable properties, look at the beginning of the rules
20+
files in the SDK, at tools/ant/build.xml
21+
22+
Properties related to the SDK location or the project target should
23+
be updated using the 'android' tool with the 'update' action.
24+
25+
This file is an integral part of the build system for your
26+
application and should be checked into Version Control Systems.
27+
28+
-->
29+
<property file="ant.properties"/>
30+
31+
<!-- if sdk.dir was not set from one of the property file, then
32+
get it from the ANDROID_HOME env var.
33+
This must be done before we load project.properties since
34+
the proguard config can use sdk.dir -->
35+
<property environment="env"/>
36+
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
37+
<isset property="env.ANDROID_HOME"/>
38+
</condition>
39+
40+
<!-- The project.properties file is created and updated by the 'android'
41+
tool, as well as ADT.
42+
43+
This contains project specific properties such as project target, and library
44+
dependencies. Lower level build properties are stored in ant.properties
45+
(or in .classpath for Eclipse projects).
46+
47+
This file is an integral part of the build system for your
48+
application and should be checked into Version Control Systems. -->
49+
<loadproperties srcFile="project.properties"/>
50+
51+
<!-- quick check on sdk.dir -->
52+
<fail
53+
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
54+
unless="sdk.dir"
55+
/>
56+
57+
<!--
58+
Import per project custom build rules if present at the root of the project.
59+
This is the place to put custom intermediary targets such as:
60+
-pre-build
61+
-pre-compile
62+
-post-compile (This is typically used for code obfuscation.
63+
Compiled code location: ${out.classes.absolute.dir}
64+
If this is not done in place, override ${out.dex.input.absolute.dir})
65+
-post-package
66+
-post-build
67+
-pre-clean
68+
-->
69+
<import file="custom_rules.xml" optional="true"/>
70+
71+
<!-- Import the actual build file.
72+
73+
To customize existing targets, there are two options:
74+
- Customize only one target:
75+
- copy/paste the target into this file, *before* the
76+
<import> task.
77+
- customize it to your needs.
78+
- Customize the whole content of build.xml
79+
- copy/paste the content of the rules files (minus the top node)
80+
into this file, replacing the <import> task.
81+
- customize to your needs.
82+
83+
***********************
84+
****** IMPORTANT ******
85+
***********************
86+
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
87+
in order to avoid having your file be overridden by tools such as "android update project"
88+
-->
89+
<!-- version-tag: 1 -->
90+
<import file="${sdk.dir}/tools/ant/build.xml"/>
91+
92+
</project>

0 commit comments

Comments
 (0)