Test class not found in selected project

拈花ヽ惹草 提交于 2020-01-24 09:00:06

问题


Currently I am developing a simple program using Cucumber that will test logging in of a user on a website.

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 {

}

I also have the cucumber file as LogIn_Test.feature as follows:

Feature: Login Action

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

But whenever I try to run the TestRunner class as a JUnit test, I get the error:

Test class not found in selected project.


回答1:


you should to specify the cucumber feature file:

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:cucumberTest/LogIn_Test.feature")
public class TestRunner {

}

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\




回答2:


I know this is an older question that I'm responding to, but you seem to be missing the glue option in your @CucumberOptions():

@CucumberOptions(
    features = "Feature"
    ,glue={"stepDefinition"}
    )


来源:https://stackoverflow.com/questions/30782803/test-class-not-found-in-selected-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!