英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论