当前位置: 首页 > 知识库问答 >
问题:

Cucumber JUnit测试未将特性粘合到stepdefinitions

马峻
2023-03-14

我已经用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似乎忽略了我的胶水代码。即使我输入了一个无效的路径,它也不会抱怨。

共有2个答案

寇坚成
2023-03-14

给出glue=“com.bsautoweb.stepdefinitions”

宇文峰
2023-03-14

将glue选项设置为com/bsautoweb/stepdefinitions或java包样式com。B自动网络。步骤定义

 类似资料:
  • 我有以下由Spring MVC API提供的具有单endpoint的结构: 接口 控制器 为了测试API,我首先创建了,并且能够成功地执行它:

  • 我需要在悬停时测试背景颜色到#F67621的变化。将背景颜色代码与预定义的预期值进行比较。我使用XPath作为选择器。 上面的代码可以有人建议我如何检查悬停按钮 CSS上面提到的代码如下:

  • 我在这里给我的课做了注解 此外,还对我的测试方法进行了这样的注解 最后,配置我的build.gradle defaultConfig和依赖项,如下所示

  • 我想知道粘性和非粘性会议之间的区别。我从网上读到的: 粘滞:只有一个会话对象将在那里。 非粘性会话:每个服务器节点的会话对象

  • 我有一个在PlayFramework1.2.5中运行的多用户应用程序。 有时,用户会开始收到324个特定URL的错误,该URL在几分钟前就为他们工作过。(324=Chrome中未接收到数据,服务器在IE8中关闭了连接)。一旦收到此消息,他们将继续收到错误。 我可以看到请求到达运行Play Framework的计算机(通过Wireshark),但请求似乎没有到达Play控制器。(作为控制器中第一步的