黄瓜无法找到步骤定义,即使它具有正确的步骤定义设计。

huangapple go评论75阅读模式
英文:

Cucumber is unable to find the Step Definition even it have proper Stepdefinition designed

问题

我正在准备Selenium Cucumber框架,但遇到了问题。步骤定义路径在glue中被正确定义,但无法找到Cucumber的步骤定义。

已安装的jar包:
Cucumber-java,
Cucumber-core,
Cucumber-junit,
gherkin,
junit,
selenium standalone

测试运行器TestRunner

import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/java/features",glue={"src/test/java/stepDefinitions"})
public class TestRunner {

}

文件夹结构

(图片已省略)

我尝试过使用Cucumber Java 8,但甚至无法获得那些Given、When、Then注解。

英文:

I'm preparing the Selenium Cucumber framework and I'm facing an issue. Step definition path is defined as correct in the glue but it is not able to find the cucumber step definition

Installed jars:
Cucumber-java,
Cucumber-core,
Cucumber-junit,
gherkin,
junit,
selenium standalone

TestRunner

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/java/features",glue={"src/test/java/stepDefinitions"})
public class TestRunner {

}

Folder Structure

黄瓜无法找到步骤定义,即使它具有正确的步骤定义设计。

I tried with Cucumber Java 8 but I wasn't even able to get that Given, When, Then annotations.

答案1

得分: 1

尝试将粘合定义更改为以下方式:

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/java/features",
        glue = "stepDefinitions"
)
public class TestRunner{

}

其中 stepDefinitions 是您步骤定义文件的包名称

不需要提供完整路径。

英文:

Try changing the glue definition like this:

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/java/features",
        glue = "stepDefinitions"
)
public class TestRunner{

}

Where stepDefinitions is a package name of your step definition file.

It is not necessary to provide the full path.

huangapple
  • 本文由 发表于 2020年9月16日 22:16:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/63922003.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定