java黄瓜任务
我如何告诉ant在一个文件夹中执行所有cucumber测试(特性、实现)
我无法用这个例子
<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>
# 1 楼答案
选项:
在您的情况下,将
<arg value="src/test/resources"/>
更改为要运行的目录。请注意,您可以指定多个单独的文件和目录,这些文件和目录以空格分隔# 2 楼答案
您可以编写自己的构建文件,而不是使用github提供的示例附带的构建文件
尝试使用ant的Junit任务从ant运行Junit测试文件。将“@Cucumber.Options”注释的“format”设置为指向包含您的功能的目录
范例
要运行Junit测试,请将以下目标添加到构建文件中
将执行
<test name="com.example.YourTestClass" haltonfailure="no" outfile="result" >
中指定的Juint测试。你的测试课。java将看起来像这样所有保存在src/test/features中的功能文件将在执行构建文件时运行
# 3 楼答案
我也遇到了同样的问题,通过声明顶级包名解决了这个问题,比如在你的例子中,包名是“cucumber.examples.java.helloworld”,只需像这样声明cucumber
在你的蚂蚁任务。它在我这边起作用