我如何知道蚂蚁的文件夹中执行所有黄瓜测试(功能,实现)?
我坚持用这个例子
<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>
用法:java的cucumber.cli.Main [选项] [[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.
你的情况-修改<arg value="src/test/resources"/>
您要针对其运行目录。 请注意,您可以指定多个独立的文件和目录的空间分隔。
我也面临同样的问题,通过声明顶部的包名你情况下,包装名称,比如解决的问题是“cucumber.examples.java.helloworld”就宣布这样才黄瓜
<arg value="--glue"/>
<arg value="cucumber"/>
在你ant任务。 它的工作在我结束。
而不是使用以及来自GitHub上的样品提供的构建文件,你可以写自己的编译文件。
尝试运行从蚂蚁使用Ant的junit任务JUnit测试文件。 “@ Cucumber.Options”批注集“格式”指向有你的特点的目录。
例
要运行JUnit测试,添加以下目标构建文件,
<junit printsummary="yes" failureproperty="junit.failure">
<classpath refid="id_of_the_path_to_find_JARS/.class files"></classpath>
<test name="com.example.YourTestClass" haltonfailure="no" outfile="result" >
<formatter type="plain"/>
<formatter type="xml"/>
</test>
</junit>
在指定的测试Juint <test name="com.example.YourTestClass" haltonfailure="no" outfile="result" >
将被执行。 该YourTestClass.java看起来像这样...
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"html:target/cucumber-html","junit:target/cucumber-junit/Webpage.xml"},features = "src/test/features")
public class YourTestClass {
}
所有保存在SRC /测试功能的文件/功能将在执行构建文件运行