Warm tip: This article is reproduced from serverfault.com, please click

java- Cucumber JUnit测试未将功能粘贴到stepdefinitions

(java - Cucumber JUnit tests not gluing feature to stepdefinitions)

发布于 2019-09-05 15:28:59

我已经在Java中设置了一个 Cucumber 项目,在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”选项卡中的步骤,则会收到以下消息

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

我的测试跑步者班级看起来像这样,

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忽略了我的粘合代码。即使输入无效路径,也不会抱怨。

Questioner
Ethranes
Viewed
0
Grasshopper 2019-09-06 22:23:00

将胶水选项设置为com/bsautoweb/stepdefinitions或Java包样式com.bsautoweb.stepdefinitions