Cucumber在运行代码时无法找到StepDefinition

Cucumber在运行代码时无法找到StepDefinition

本文介绍了Cucumber在运行代码时无法找到StepDefinition,而是使用选项"Find Step"手动查找.可以找到步骤定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在如下定义的项目结构中,

In the project Structure defined like below,

  • src/main/java-配置(RunCukesTest.java)-StepDefinitions
  • src/test/resources-功能/登录
  • src/main/java-- Config (RunCukesTest.java)-- StepDefinitions
  • src/test/resources-- features/login

当我从RunCukesTest.java using RunAs --> JUnit Test,运行时,跑步者无法找到步骤定义

When I run from RunCukesTest.java using RunAs --> JUnit Test, Step Definitions cannot be found by runner

当我单击查找步骤"时,将打开正确的文件.由于几天前代码在运行,因此无法理解问题出在哪里.文件从此处下载

When I click find Step, opens the right file. Couldn't understand where the issue is because the code was running few days back. File is downloaded from here

https://drive.google.com/open?id=0B4SgyzyvwKhiVTRmRDZuNXNTSjA

Runner类代码

package helpers;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
//features= "src/test/resources/features/navigation",

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"classpath:features"},
        plugin = {"pretty", "html:target/cucumber-html-report"},
        tags = {"@OnlyOneTime"},
//      dryRun = true,
        monochrome = true
        )
public class RunCukesTest{

}

推荐答案

胶水代码应该具有指向钩子和步骤定义的路径

Glue code is supposed to have path to hooks and step definitions

因此修改为glue={"helpers","stepDefinitions"}而不是glue={"helpers","classpath/stepDefinitions", "classpath/stepDefinitions.LogIn","classpath/stepDefinitions.Publish"}

请参考此链接在github上有类似问题

这篇关于Cucumber在运行代码时无法找到StepDefinition,而是使用选项"Find Step"手动查找.可以找到步骤定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 13:00