Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Cucumber JUnit测试未将特性粘合到步骤定义_Java_Junit_Cucumber_Cucumber Jvm - Fatal编程技术网

Java Cucumber JUnit测试未将特性粘合到步骤定义

Java Cucumber JUnit测试未将特性粘合到步骤定义,java,junit,cucumber,cucumber-jvm,Java,Junit,Cucumber,Cucumber Jvm,我已经用java设置了一个cucumber项目,在我的EclipseIDE中,我可以直接运行我的功能文件,测试将完成。但是,当我将它们作为JUnit测试运行时,它们不会运行,在控制台中它们显示为 @When("^user navigates to Login Page$") public void user_navigates_to_Login_Page() throws Throwable { // Write code here that turns the phrase above

我已经用java设置了一个cucumber项目,在我的EclipseIDE中,我可以直接运行我的功能文件,测试将完成。但是,当我将它们作为JUnit测试运行时,它们不会运行,在控制台中它们显示为

@When("^user navigates to Login Page$")
public void user_navigates_to_Login_Page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}
如果我双击JUnit选项卡中的步骤,我会得到以下消息

“在所选项目中找不到测试类”

我的试跑课是这样的

package com.bsautoweb.runner;

import java.io.File;

import org.junit.AfterClass;
import org.junit.runner.RunWith;

import com.cucumber.listener.Reporter;

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

@RunWith(Cucumber.class)
@CucumberOptions(glue = {"src/test/java/com/bsautoweb/stepdefinitions"}, features = {"src/test/resources/features/"},
plugin = "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html",
monochrome = true
)

public class Testrunner {
    @AfterClass
    public static void writeExtentReport() {
        Reporter.loadXMLConfig(new File("config/report.xml"));

    }
}
我的文件夹结构如下所示


JUnit似乎忽略了我的胶水代码。即使我输入了无效的路径,它也不会抱怨。

将胶水选项设置为
com/bsautoweb/stepdefinitions
或java包样式
com.bsautoweb.stepdefinitions
Give glue=“com.bsautoweb.stepdefinitions”

将胶水选项设置为
com/bsautoweb/stepdefinitions
嗨,这对我有用,谢谢,如果你想回答,我可以接受。这是正确的答案。Java包样式可能更好一些,因为它强调了它不是项目中的文件夹,而是名称空间。