matcauthon matcauthon - 1 year ago 149
Groovy Question

Cucumber-JVM ant task

How do i tell ant to execute all cucumber tests (features, implementations) in a folder?

I'm stuck using this example

<target name="runcukes" depends="compile-test">
<mkdir dir="target/cucumber-junit-report"/>
<java classname="cucumber.cli.Main" fork="true" failonerror="false" resultproperty="cucumber.exitstatus">
<classpath refid="classpath"/>
<arg value="--format"/>
<arg value="junit:target/cucumber-junit-report/allcukes.xml"/>
<arg value="--format"/>
<arg value="pretty"/>
<arg value="--format"/>
<arg value="html:target/cucumber-html-report"/>
<arg value="--glue"/>
<arg value=""/>
<arg value="src/test/resources"/>

<junitreport todir="target/cucumber-junit-report">
<fileset dir="target/cucumber-junit-report">
<include name="allcukes.xml"/>
<report format="frames" todir="target/cucumber-junit-report"/>

<fail message="Cucumber failed">
<equals arg1="${cucumber.exitstatus}" arg2="0"/>

Answer Source

Usage: java cucumber.cli.Main [options] [ [FILE|DIR][:LINE[:LINE]*] ]+


-g, --glue PATH Where glue code (step definitions and hooks) is loaded from.
-f, --format FORMAT[:OUT] How to format results. Goes to STDOUT unless OUT is specified.
                                Available formats: junit, html, pretty, progress, json, json-pretty.
-t, --tags TAG_EXPRESSION Only run scenarios tagged with tags matching TAG_EXPRESSION.
-n, --name REGEXP Only run scenarios whose names match REGEXP.
-d, --dry-run Skip execution of glue code.
-m, --monochrome Don't colour terminal output.
    --dotcucumber Where to write out runtime information.
-v, --version Print version.
-h, --help You're looking at it.

In your case - change the <arg value="src/test/resources"/> to directory you want to run against. Note that you can specify multiple individual files and directories space-separated.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download