Cucumber JUnit 测试未将功能粘合到步骤定义

Cucumber JUnit tests not gluing feature to stepdefinitions

我在 java 中设置了一个黄瓜项目,在我的 Eclipse IDE 中,我可以直接 运行 我的功能文件,测试将完成。但是,当我 运行 将它们作为 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 选项卡中的步骤,我会收到以下消息

"Test class not found in selected Project"

我的测试 运行ner class 看起来像这样,

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

给胶水=》com.bsautoweb.stepdefinitions