目前我正在开发一个使用 Cucumber 的简单程序,该程序将测试用户在网站上的登录情况。
这是我的 TestRunner 文件:
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 cucumber 文件:
功能:登录操作
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 测试运行时,我都会收到错误消息:
在所选项目中找不到测试类。
最佳答案
你应该指定 cucumber 功能文件:
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:cucumberTest/LogIn_Test.feature")
public class TestRunner {
}
确保你已经将它放在与包名相同路径下的资源文件夹中,即:workspace\project-name\src\test\resources\cucumberTest\
关于java - 在所选项目中找不到测试类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30782803/