从黄瓜中的功能生成java测试类

时间:2014-08-08 13:56:28

标签: java unit-testing cucumber bdd

我是黄瓜的新手,想要了解是否有任何插件可以从黄瓜功能文件中生成java测试类代码。

Example : I have the below scenario - 
  Scenario: Determine past date
    Given today is 2011-01-20
    When I ask if Jan 19, 2011 is in the past
    Then the result should be yes

有没有办法用每种方法生成测试类? 我只是想生成类的骨架,以便加快开发过程。

1 个答案:

答案 0 :(得分:3)

您可以使用如下的运行程序类运行该功能:

import org.junit.runner.RunWith;

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

@RunWith(Cucumber.class)
@CucumberOptions(
dryRun = false,
strict = true,
plugin = {"pretty"},
features = {"path/to/features"},
glue = {"package.of.steps"},
tags = {"@TagsToRun"})

public class MyCucumberTestRunnner {
    public MyCucumberTestRunnner() {
    }
}

这可以作为JUnit Test执行,而Cucumber会告诉你,缺少步骤并会为你提供Step Skeletons。

如果胶水代码在同一个包装中,您不需要提供信息

相关问题