问题描述
当前,我正在使用Cucumber开发一个简单的程序,该程序将测试用户在网站上的登录.
Currently I am developing a simple program using Cucumber that will test logging in of a user on a website.
这是我的TestRunner文件:
Here is my TestRunner file:
package cucumberTest;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "Feature")
public class TestRunner {
}
我还有黄瓜文件LogIn_Test.feature,如下所示:
I also have the cucumber file as LogIn_Test.feature as follows:
功能:登录操作
Scenario: Successful Login with Valid Credentials
Given User is on Home Page
When User Navigate to LogIn Page
And User enters UserName and Password
Then Message displayed Login Successfully
Scenario: Successful LogOut
When User LogOut from the Application
Then Message displayed LogOut Successfully
但是每当我尝试将TestRunner类作为JUnit测试运行时,都会收到错误消息:
But whenever I try to run the TestRunner class as a JUnit test, I get the error:
在所选项目中找不到测试类.
Test class not found in selected project.
推荐答案
您应指定黄瓜特征文件:
you should to specify the cucumber feature file:
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:cucumberTest/LogIn_Test.feature")
public class TestRunner {
}
确保已将其放在与包名称相同路径下的资源文件夹中,即:workspace\project-name\src\test\resources\cucumberTest\
make sure you have placed it on the resource folder under the same path as the package name, ie: workspace\project-name\src\test\resources\cucumberTest\
这篇关于在所选项目中找不到测试类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!