cucumber JVM和apache ant的兼容性



我正在研究一个开源项目。到目前为止,它使用Jbehave和Ant。但是我想用Cucumber JVM代替JBehave的使用。我想知道黄瓜JVM是否与Apache ANT兼容,如果是的话,我怎么能在同一个项目中用黄瓜JVM代替JBehave的使用?

您确实可以通过使用JUnit运行器将cucumber-jvm与Ant一起使用。然后像执行其他JUnit测试一样执行Cucumber-jvm测试。

例如,下面是一个简单的JUnit测试,它将在类路径上执行特性文件:
package com.example.cuke;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = "json:target/report.json")
public class RunCukeTest {
}

您可以在编译之后执行这个测试,在您的build.xml中使用以下命令:

  <target name="test-cuke">
    <junit printsummary="yes" haltonfailure="no">
      <classpath refid="test.classpath" />
      <test name="com.example.cuke.RunCukeTest"
            haltonfailure="no" todir="${report.dir}">
        <formatter type="plain" />
        <formatter type="xml" />
      </test>
    </junit>
  </target>

您需要确保特性文件和步骤定义都在类路径test.classpath上。完成后,cucumber-jvm会处理剩下的部分。

最新更新