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="cucumber.examples.java.helloworld"/>
<arg value="src/test/resources"/>
</java>
<junitreport todir="target/cucumber-junit-report">
<fileset dir="target/cucumber-junit-report">
<include name="allcukes.xml"/>
</fileset>
<report format="frames" todir="target/cucumber-junit-report"/>
</junitreport>
<fail message="Cucumber failed">
<condition>
<not>
<equals arg1="${cucumber.exitstatus}" arg2="0"/>
</not>
</condition>
</fail>
</target>
I also faced same problem and solved by declaring top package name like in you case the package name is "cucumber.examples.java.helloworld" Just declare only cucumber like this
in you ant task. It's working at me end.
Instead of using the build file provided along with the samples from github, you can write your own build file.
Try running the Junit test file from ant using ant's Junit task. Set "format" of "@Cucumber.Options" annotation to point to the directory having your features.
Example
To run the Junit test,add the following target to your build file,
The Juint test specified in the
<test name="com.example.YourTestClass" haltonfailure="no" outfile="result" >
will be executed. The YourTestClass.java will look like this...All the feature files kept in src/test/features will run while executing the build file
Options:
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.