簡體   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