[cucumber-jvm] Run all tests via maven/command line when Cucumber.Options is set?

6,264 views
Skip to first unread message

Christian

unread,
May 29, 2014, 9:56:25 AM5/29/14
to cu...@googlegroups.com

Hi,

Given someone has added the following:

@Cucumber.Options(
        format   = {"pretty", "html:target/cucumber", "json:target/cucumber.json"},
        tags     = "@myTag",
        features = "src/test/resources/features"  )

Is there a way to make sure all scenarios are executed when running maven via a command line, e.g. on a continuous integration platform, like the following:

mvn clean test -Dcucumber.options="src/test/resources/features --tags @myTest"

Put differently, is there a command line option to force cucumber to "execute all features", e.g. using something like

mvn clean test -Dcucumber.options="src/test/resources/features --tags "

And am I correct in assuming

--tags ~@doNotRunMe

will execute all tags except the one mentioned?

If so, would

--tags ~@nonexistantTag

achieve what I'm after?

Thanks,

Christian

P.S.: I'm cross-posting this from stackoverflow; for some reason I posted it there before being told to come here...
http://stackoverflow.com/questions/23934915/make-cucumber-jvm-run-all-tests-on-continuous-integration-platform-when-kicked-o

Björn Rasmusson

unread,
May 30, 2014, 5:42:41 AM5/30/14
to cu...@googlegroups.com
Christian wrote:

Hi,

Given someone has added the following:

@Cucumber.Options(
        format   = {"pretty", "html:target/cucumber", "json:target/cucumber.json"},
        tags     = "@myTag",
        features = "src/test/resources/features"  )

Is there a way to make sure all scenarios are executed when running maven via a command line, e.g. on a continuous integration platform, like the following:

mvn clean test -Dcucumber.options="src/test/resources/features --tags @myTest"

Put differently, is there a command line option to force cucumber to "execute all features", e.g. using something like

mvn clean test -Dcucumber.options="src/test/resources/features --tags "

And am I correct in assuming

--tags ~@doNotRunMe

will execute all tags except the one mentioned?

If so, would

--tags ~@nonexistantTag

achieve what I'm after?

Yes,

mvn clean test -Dcucumber.options="--tags ~@nonexistantTag"

should execute all scenarios (even though @CucumberOptions specified tags = "@myTag")
See also the README.md of the cucumber-java-skeleton project for more examples.

Best Regard
Björn

Christian

unread,
May 30, 2014, 6:21:23 AM5/30/14
to cu...@googlegroups.com

On Friday, May 30, 2014 10:42:41 AM UTC+1, Björn Rasmusson wrote:

Put differently, is there a command line option to force cucumber to "execute all features", e.g. using something like

mvn clean test -Dcucumber.options="src/test/resources/features --tags "

...

If so, would

--tags ~@nonexistantTag

achieve what I'm after?

Yes,

mvn clean test -Dcucumber.options="--tags ~@nonexistantTag"

should execute all scenarios (even though @CucumberOptions specified tags = "@myTag")
See also the README.md of the cucumber-java-skeleton project for more examples.


Thank you!

Just had the help printed out and thought I'd copy it in here, in case someone else wants to have a look:
Usage: java cucumber.api.cli.Main [options] [ [FILE|DIR][:LINE[:LINE]*] ]+

Options:

    -g, --glue PATH                        Where glue code (step definitions and hooks) is loaded from.
    -f, --format FORMAT[:PATH_OR_URL]      How to format results. Goes to STDOUT unless PATH_OR_URL is specified.
                                           Built-in FORMAT types: junit, html, pretty, progress, json.
                                           FORMAT can also be a fully qualified class name.
    -t, --tags TAG_EXPRESSION              Only run scenarios tagged with tags matching TAG_EXPRESSION.
    -n, --name REGEXP                      Only run scenarios whose names match REGEXP.
    -d, --[no-]-dry-run                    Skip execution of glue code.
    -m, --[no-]-monochrome                 Don't colour terminal output.
    -s, --[no-]-strict                     Treat undefined and pending steps as errors.
        --snippets [underscore|camelcase]  Naming convention for generated snippets. Defaults to underscore.
        --dotcucumber PATH_OR_URL          Where to write out runtime information. PATH_OR_URL can be a file system
                                           path or a URL.
    -v, --version                          Print version.
    -h, --help                             You're looking at it.
 
Looking at that, I wonder if there is a page that explains what a valid TAG_EXPRESSION looks like?
I'll set up another email thread to ask that in a separate chain... :)

Brgrds,

Ch

Partha Sarathi Das

unread,
Dec 26, 2018, 9:49:52 PM12/26/18
to Cukes
Hi,

I'm trying with this command. 

mvn clean -f E:\gitClone\demoBDDFramework test -Dcucumber.options="E:\gitClone\demoBDDFramework\src\main\java\com\assetvantage\featureFile --gule E:\gitClone\demoBDDFramework\src\main\java\com\assetvantage\StepDefination --tags @SmokeTest" -e 

and getting this

D:\apache-maven-3.6.0\bin>mvn clean -f E:\gitClone\demoBDDFramework test -Dcucumber.options="E:\gitClone\demoBDDFramework\src\main\java\com\assetvantage\featureFile --gule E:\gitClone\demoBDDFramework\src\main\java\com\assetvantage\StepDefination --tags @SmokeTest" -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< Demo-Framework:demo >-------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo ---
[INFO] Deleting E:\gitClone\demoBDDFramework\target
[INFO]
[INFO] --- maven-resources-plugin:2.4:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\gitClone\demoBDDFramework\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 28 source files to E:\gitClone\demoBDDFramework\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.4:testResources (default-testResources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\gitClone\demoBDDFramework\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to E:\gitClone\demoBDDFramework\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ demo ---
[INFO] Surefire report directory: E:\gitClone\demoBDDFramework\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.879 s
[INFO] Finished at: 2018-12-21T14:24:39+05:30
[INFO] ------------------------------------------------------------------------

Please suggest.
Reply all
Reply to author
Forward
0 new messages