【发布时间】:2019-09-05 15:28:59
【问题描述】:
我已经在 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 选项卡中的步骤,我会收到以下消息
“在所选项目中找不到测试类”
我的测试运行器类看起来像这样,
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 junit cucumber cucumber-jvm