cucumber jvm CucumberException:在[]处未找到任何功能
在cucumber-jvm、Maven、junit设置中,我的testRunner文件是cucumber jvm CucumberException:在[]处未找到任何功能,cucumber,cucumber-jvm,cucumber-junit,Cucumber,Cucumber Jvm,Cucumber Junit,在cucumber-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", "co
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中的“features”选项,它将尝试在与我的testrunner.java相同的目录中查找功能文件
cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]
如果我把功能文件放在那里,它就会工作
我的问题是,为什么我的功能文件没有从我以前的位置获取,我认为这是cucumber-maven设置的默认文件结构
我怎样才能把它从那里接起来?谢谢你的帮助 您的测试运行程序和功能文件具体在哪里?我有以下设置,可以完美地工作:
src/test/
java/
com/mypackage/
TestRunner.java
StepDefinition.java
resources
com/mypackage/
fancy.feature
Maven/Cuke约定将从tests/java目录和test/resources目录中的功能文件执行测试。我的测试跑步者与你的基本相同,但选项较少:
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty"})
public class TestRunner { }
如果您还没有找到答案,希望这对您有所帮助。我有一个与您类似的设置(不使用Maven/Cucumber约定)。在我的选项中,我没有从根目录指定路径,而是从项目的源文件夹指定路径,该文件夹中保存了要素。这是有道理的,因为否则测试只能从您的机器上运行 就你而言,我认为应该是:
features = "src/main/resources"
如果您提供的是功能文件的完整路径,即 “C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources”在您的查询中,请用“\\”(双反斜杠)替换“/”字符,再试一次,如下所示 “C:\\Users\\sarthak.dayanand\\Documents\\WebRefreshTest\\CukeAutomation\\LebaraWebAutomationTest1\\src\main\\resources\\abc.feature”只需添加功能={“classpath:features/features.feature”},并且该功能必须在测试/resources/features/feature.feature下
@CucumberOptions(
format = {"pretty", "html:target/html"},
features = {"classpath:features/feature.feature"},
snippets = SnippetType.CAMELCASE
注意类路径
如果使用maven编译代码,请打开目标/测试类/功能,然后将功能文件放在运行程序和步骤文件所在的src/test/java下,您将看到功能.feature 通过将其置于src/main/java下,问题将得到解决
始终欢迎您的感谢:)这是一个使用最新cucumber版本的git回购: 克隆此repo并在本地计算机上运行。给定的
@已定义且应通过。@Then
和@When
应显示为未定义
它的输出应该是这样的:
使用上述结构:
src/test/java/io/cucumber/
{Step definitions java and run cucucumber test files here}
src/test/resources/io/cucumber/
{featurefiles here}
您可以使用/gradlew clean build
使用/gradlew clean test--info
如果可行,那么在您的项目中使用相同的格式。只需将.Feature更改为.Feature问题已为我解决
另外,请确保根据您的功能文件夹在CucumberOptions中严格提及功能的路径
一些在线教程提到了。Feature带来了这个问题
因此,改变案例将解决这个问题
还有另一个实例出现“未找到功能”错误。由于没有类似的问题,我在这个答案下发布了解决方案
在Maven中设置Cucumber项目后,我第一次尝试运行Runner文件时遇到了这个错误。我找到的解决方案如下:转到Windows资源管理器中“功能”文件所在的文件夹。检查您尝试运行的功能文件的大小。如果大小为“0”KB,它将显示“未找到功能”错误。对文件进行一些更改,直到显示大于零的值。更改后再次运行。从“.features”更改为“.features”为我修复了它;感谢您不要将测试代码放在src/main下。该文件夹通常包含用于生产的代码,您不希望测试代码用于生产。
//Removing the space between "**classpath**" and "**:com/**" helped.
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"classpath:com/tk/feature/"}, //NOTE: NO SPACE
glue = {"classpath: com.tk.cucumber"},
plugin = {
"pretty",
"html:build/reports/cucumber"
,"json:build/reports/cucumber-tests/test.json"}
)
public class RunAPITests {}