This will enable cucumber-android test projects that are started through the activity manager (adb shell am instrument
) to receive additional Cucumber options from the command line.
General
A normal test project would be started like this:
adb shell am instrument -w com.mypackage.app.test/cucumber.api.android.CucumberInstrumentation
The activity manager (am
) supports additional extras for the instrument
command:
adb shell am instrument -w -e key value com.mypackage.app.test/cucumber.api.android.CucumberInstrumentation
Multiple extras can be passed like this:
-e key1 value1 -e key2 value2
Supported Cucumber options
am instrument argument | Cucumber option |
-e glue PATH | --glue PATH |
-e format FORMAT[:PATH_OR_URL] | --format FORMAT[:PATH_OR_URL] |
-e tags TAG_EXPRESSION | --tags TAG_EXPRESSION |
-e name REGEXP | --name REGEXP |
-e dryRun true -e noDryRun true | --[no-]-dry-run |
-e monochrome true -e noMonochrome true | --[no-]-monochrome |
-e strict true -e noStrict true | --[no-]-strict |
-e snippets [underscore|camelcase] | --snippets [underscore|camelcase] |
-e dotcucumber PATH_OR_URL | --dotcucumber PATH_OR_URL |
-e features [ [FILE|DIR][:LINE[:LINE]*] ]+ | [ [FILE|DIR][:LINE[:LINE]*] ]+ |
Single argument for Cucumber options
A single argument extra for the Cucumber options is also supported:
adb shell am instrument -w -e cucumberOptions "--dry-run --name 'My Test'" com.mypackage.app.test/cucumber.api.android.CucumberInstrumentation
When using cucumberOptions
all other Cucumber option extras will be ignored.
A few things to note
- You cannot pass just a key without a value, that means a boolean option such as
--strict
would have to be passed like this: -e strict true
- Feature references can be passed:
-e features [ [FILE|DIR][:LINE[:LINE]*] ]+
- Values containing spaces need to be passed like this:
-e name "'My Feature'"
- It is not possible to pass the same key multiple times, e. g.
-e name Feature1 -e name Feature2
would result in the first name argument being overwritten by the second name argument: The test app would only see Feature2
.
In order to pass options more than once, you would need to separate the values by two dashes --
, like this: -e name Feature1--Feature2
This pull request also adds support for the following legacy test runner arguments
am instrument argument | Description |
-e count true | Count the number of tests (scenarios) |
-e debug true | Wait for a debugger to attach before starting to execute the tests. Note: This was added by PR #613 already. |
-e log true | Enable Cucumber dry-run (same as --e dryRun true) |
-e coverage true | Enable EMMA code coverage |
-e coverageFile "/path/coverage.ec" | Set the file name and path of the EMMA coverage report |
Asking for comments from the community, especially on the selection of the option value separator. I don't particularly like the two dashes, but it works. Does anyone have a better suggestion?
The requirements are simple: It has to be a character or separator that is
- command line compatible (that means
&
and |
will not work)
- not already used by Cucumber (e. g.
,
as in --tags @tag1,@tag2
- unlikely to appear in any feature name, file/path/url name, or tag name
Thanks