首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cucumber-JVM ant任务

Cucumber-JVM ant任务
EN

Stack Overflow用户
提问于 2012-07-13 15:32:35
回答 3查看 7.3K关注 0票数 3

如何告诉ant执行文件夹中的所有cucumber测试(特性、实现)?

我被这个例子卡住了。

代码语言:javascript
复制
<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>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-15 06:14:59

行用法: java cucumber.cli.Main选项文件|目录:行:行*] ]+

选项:

代码语言:javascript
复制
-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"/>更改为您想要运行的目录。请注意,您可以指定多个单独的文件和目录,以空格分隔。

票数 6
EN

Stack Overflow用户

发布于 2014-04-11 15:52:43

我也遇到了同样的问题,通过声明顶级包名来解决这个问题,比如在您的例子中,包名是"cucumber.examples.java.helloworld“,只需像下面这样声明cucumber

代码语言:javascript
复制
 <arg value="--glue"/>
 <arg value="cucumber"/>

在你的蚂蚁任务中。它在我这端起作用了。

票数 1
EN

Stack Overflow用户

发布于 2012-12-26 17:53:29

您可以编写自己的构建文件,而不是使用随github提供的示例一起提供的构建文件。

尝试使用ant的 Junit 任务从ant运行Junit测试文件。将"@Cucumber.Options“注释的"format”设置为指向具有您的功能的目录。

示例

要运行Junit测试,请将以下目标添加到构建文件中,

代码语言:javascript
复制
<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>

将执行<test name="com.example.YourTestClass" haltonfailure="no" outfile="result" >中指定的Juint测试。YourTestClass.java将看起来像这样...

代码语言:javascript
复制
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/test/features中的所有要素文件将在执行构建文件时运行

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11466040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档