黄瓜功能文件没有在Java类中获取步骤定义但运行Junit后控制台中没有错误

问题描述 投票:0回答:1

Project Structure-image Structure我正在为我的java项目编写一些黄瓜测试。当运行黄瓜类时,控制台中没有发生错误,但是根据步骤定义脚本,我已经让脚本调用浏览器,因此根据我的假设,黄瓜类不会调用步骤定义类或粘合剂。你可以检查并告诉我为什么不调用它。

Code:
@RunWith(Cucumber.class)
    @CucumberOptions(
    features={"F:/Selinium/practise-cucumber/practise1/features/login.feature"},
    glue={"F:/Selinium/practise-cucumber/practise1/src/Stepdefinition/loginmethod.java"})
    public class Runcucumber {   
    }

Step Definition code: 
public class loginmethod  {
    public WebDriver driver ;
    @Given("^User is on Home Page$")
    public void user_is_on_home_page() throws Throwable{
        System.out.println("homepagre");
        System.setProperty("webdriver.chrome.driver",
                "F:/Selinium/practise-cucumber/practise1/driver/chromedriver1.exe");
        WebDriver driver = new ChromeDriver();      
        driver.get("https://www.google.com/");
        System.out.println("lUNCHED homepagre");
    }    
Browser should be invoked     

Console output Structure

selenium-webdriver cucumber cucumber-java cucumber-junit
1个回答
0
投票

你可以把你的Runcucumber类名改为RuncucumberTest然后再试一次。它发生在我身上一次。

@RunWith(Cucumber.class)
    @CucumberOptions(
    features={"F:/Selinium/practise-cucumber/practise1/features/login.feature"},
    glue={"F:/Selinium/practise-cucumber/practise1/src/Stepdefinition/loginmethod.java"})
    public class RuncucumberTest {   
    }
© www.soinside.com 2019 - 2024. All rights reserved.