繁体   English   中英

无法在 Intellij 中使用 Runner 运行测试

[英]Unable to Run tests using Runner in Intellij

尝试使用运行器运行测试时,我为功能文件创建了测试。 跑步者已成功构建并完成,但没有任何反应。

功能文件:

Feature: Login to Queries

  #Login in Chrome
Scenario: Login using Chrome
Given I open Chrome
When I browse to Queries
Then I login to Queries using "pcy1" and "123"£"

步骤定义(该类扩展基类):

public class login extends base {

@Given("^I open Chrome$")
public void iOpenChrome() throws Throwable {
    driver = initializeDriver();
    throw new PendingException();
}

@When("^I browse to Queries$")
public void iBrowseToQueries() {
    driver.get("https://atesting321.test/");
    throw new PendingException();
}

@Then("^I login to Queries using \"([^\"]*)\" and \"([^\"]*)\"£\"$")
public void iLoginToQueriesUsingAnd£(String username, String password) throws Throwable {
    driver.findElement(By.id("UserName")).sendKeys(username);
    driver.findElement(By.id("Password")).sendKeys(password);
    driver.findElement(By.id("btnLogin")).click();
    throw new PendingException();
}

赛跑者

@RunWith(Cucumber.class)
@CucumberOptions(
    features= "src/test/java/features/login",
    glue= "stepDefinitions")

public class RunTest {
public static void main (String[] args)
{}

基类(用作全局变量)

public class base {

public WebDriver driver;
public Properties prop;
public ChromeOptions coptions;

public WebDriver initializeDriver() throws IOException
{
    prop= new Properties();

    String browserName= "chrome";
    System.out.println(browserName);
    String pathToDriver = "";

    if(browserName.equals("chrome"))
    {
        pathToDriver = "C:\\Repositories\\automationProject\\webDrivers\\chromedriver.exe";
        System.setProperty("webdriver.chrome.driver", pathToDriver);
        coptions.addArguments("disable-infobars");
        coptions.addArguments("--start-maximized");
        driver= new ChromeDriver(coptions);
        //execute in chrome driver

    }

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    return driver;
}

当我运行 RunTest java 文件时,我得到以下结果:

进程以退出代码 0 结束

文件路径

当我开始使用 Cucumber 时,我遇到了同样的问题,它就像没有配置跑步者一样。

转到运行配置并删除第一次运行代码时在那里创建的内容。 在此之后,代码将通过您的 RunTest,制作胶水并运行功能文件。

您的 runner 类不应包含 main 方法:

@RunWith(Cucumber.class)
@CucumberOptions(
    features= "src/test/java/features/login",
    glue= "stepDefinitions")

public class RunTest {

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM