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

我已经在 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"));


    }

}

我的文件夹结构如下所示

http://img.mukewang.com/64aface40001ed7e02150283.jpg

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



30秒到达战场
浏览 89回答 2
2回答

炎炎设计

将glue选项设置为com/bsautoweb/stepdefinitions或java包样式com.bsautoweb.stepdefinitions

慕运维8079593

给glue =“com.bsautoweb.stepdefinitions”
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java