黄瓜JVM CucumberException:没什么特点找到在[](cucumber jvm Cu

2019-08-07 15:42发布

在我的黄瓜-jvm,Maven的,JUnit的设置,我有我的TestRunner文件

package com.lebara.testrunner;

import cucumber.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(

glue = {"com.lebara.stepdefs","com.lebara.framework.main", "com.lebara.testrunner"},
features = "C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources",
format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-report.json"},
tags = {"@UserJourney"}

)
public class RunCukesTest {
}

我在上面提到的目录中我有文件。

如果我运行它,我得到以下异常:

cucumber.runtime.CucumberException: No features found at [C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources/cucumber]...

如果我删除的TestRunner的“功能”选项,它会尝试查找功能文件在同一目录作为我testrunner.java

cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]

如果我把功能文件存在,它的工作原理。

我的问题是,为什么是我的特性文件不是从我以前的位置,我认为是黄瓜的默认文件结构拿起 - Maven的设置。

我如何从那里收拾? 帮助表示赞赏。

Answer 1:

究竟哪里是你的测试运行和功能的文件? 我有以下设置,其中工程完美:

src/test/
    java/
        com/mypackage/
            TestRunner.java
            StepDefinition.java
    resources
        com/mypackage/
            fancy.feature

Maven的/黄瓜公约将有来自测试/ java目录执行的测试,并在测试/资源目录中的功能文件。 我的测试运行是基本一样的你,但用更少的选项:

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty"})
public class TestRunner { }

希望这会帮助,如果你不是已经找到了答案。



Answer 2:

我有(不使用Maven的/黄瓜公约)类似你的设置。 在我的选择,我不指定路径从发根,但在特征举行的项目的源文件夹中。 这是有道理的,因为否则测试将只能从你的机器运行的。

在你的情况,我觉得应该是:

features = "src/main/resources"


Answer 3:

只需添加功能= {“类路径:功能/ feature.feature”},并且在测试/资源/特征/ feature.feature的必备功能。

    @CucumberOptions(
        format = {"pretty", "html:target/html"},
        features = {"classpath:features/feature.feature"},
        snippets = SnippetType.CAMELCASE

注意类路径

当你,如果你正在使用maven编译代码开拓目标/测试类/功能 ,你会看到feature.feature



Answer 4:

如果您提供的功能,即文件的完整路径

“C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources”作为您的查询,通过更换“/”字符如下再试一次“\\”(双反斜线) 。

“C:\\用户\\ sarthak.dayanand \\文献\\ WebRefreshTest \\ CukeAutomation \\ LebaraWebAutomationTest1 \\ SRC \主\\资源\\ abc.feature”



Answer 5:

通过将功能文件在src / test / java下 ,其中亚军和步骤文件或者将它下的src / main / java的问题将得到解决。

随时欢迎您的感谢 。:)



文章来源: cucumber jvm CucumberException: No features found at []