简体   繁体   English

黄瓜测试未使用ant运行吗?

[英]Cucumber tests not running using ant?

I am deploying cucumber tests using ant. 我正在使用蚂蚁部署黄瓜测试。 Ant generates reports however the status of these tests are skipped and the scenario says it is undefined. Ant会生成报告,但是这些测试的状态将被跳过,并且场景表明它是未定义的。 I am wondering is it an issue with my runner class? 我想知道我的跑步者班有问题吗?

My code: 我的代码:

package cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(,
        plugin = {"html:target/cucumber-html-report","junit:target/cucumber-junit-report/test.xml"},
        features = {"src/cucumber/features"} )
public class CucumberRunner {

}

My build.xml 我的build.xml

<!-- Build targets -->
<target name="build" description="Build project" depends="clean,compile,package"/>
<target name="test" description="Test project" depends="build">
        <mkdir dir="target/cucumber-junit-report"/>
        <java classname="cucumber.api.cli.Main" fork="true" failonerror="false" resultproperty="cucumber.exitstatus">
            <classpath refid="test.classpath"/>
            <arg value="--format"/>
            <!-- creates our junit report -->
            <arg value="junit:target/cucumber-junit-report/test.xml"/>
            <arg value="--format"/>
            <arg value="pretty"/>
            <arg value="--format"/>
            <!-- creates our cucumber html friendly report -->
            <arg value="html:target/cucumber-html-report"/>
            <arg value="--format"/>
            <!-- creates our cucumber json friendly report -->
            <arg value="json:target/cucumber.json"/>
            <arg value="--glue"/>
            <!-- identifies the package (folder) where the cucumber definitions live -->
            <arg value="test.src.cucumber.features"/>
            <!-- identifies the folder where the feature files live (looks in all subfolders) -->
            <arg value="test/src/cucumber"/>
        </java>

        <!-- writes out information to junit report -->
        <junitreport todir="target/cucumber-junit-report">
            <fileset dir="target/cucumber-junit-report">
                <include name="test.xml"/>
            </fileset>
            <report format="frames" todir="target/cucumber-junit-report"/>
        </junitreport>

        <!-- checks our exit status, and determines success or failure -->
        <fail message="Cucumber failed">
            <condition>
                <not>
                    <equals arg1="${cucumber.exitstatus}" arg2="0"/>
                </not>
            </condition>
        </fail>
    </target>    

A quick look at you runner class doesn't tell me that it is broken. 快速浏览一下跑步者课程并不能告诉我它已损坏。

I would, however, reduce the problem and start with something that worked. 但是,我会减少问题并从可行的方法开始。 In this case, I would clone https://github.com/cucumber/cucumber-java-skeleton or download it as a zip and see that it worked. 在这种情况下,我将克隆https://github.com/cucumber/cucumber-java-skeleton或将其下载为zip并查看其是否有效。 I would then introduce the things you have step by step. 然后,我将逐步介绍您拥有的东西。 Very small steps and always verify that the scenarios are executed properly. 非常小的步骤,请始终验证方案是否正确执行。

You have some kind of issue and you have, at least in my opinion, a lot of things going on in your build. 您有某种问题,至少在我看来,您的构建中正在进行很多事情。

Remember Gall's law: "A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over with a working simple system." 记住加尔定律:“一个有效的复杂系统总是被发现是从一个有效的简单系统演变而来的。一个从头开始设计的复杂系统永远不会起作用,也无法进行修补以使其起作用。您必须从一个简单的工作开始系统。”

我认为您必须扩展与此类似的抽象测试类

public class TestRunner extends AbstractTestNGCucumberTests {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM