首页 文章

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

提问于
浏览
1

我是黄瓜新手,想要了解是否有任何插件可以从黄瓜功能文件生成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 回答

  • 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 .

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

相关问题