0

当我执行我的 Testng 代码时,总是会跳过测试。我收到以下错误
FAILED CONFIGURATION: @BeforeTest beforeTest

在我的代码片段下面

@Test(dataProvider = "bhaskar") 
public void f(String xpath,String values,String action,String browser) { 
    if(browser.contentEquals("common")) { 
        switch(action) { 
            case "openurl" : openurl(values); break; 
            case "verifytitle": verifytitle(values); break; 
            case "click": click(xpath); break; 
            default: System.out.println("keyword not found");
        } 
    }
} 

//-------------------------------------

public void openurl(String values) { 
    driver.get(values); 
}

public void verifytitle(String values) { 
    String title=driver.getTitle(); 
    Assert.assertEquals(title, values); 
} 

public void click(String xpath){ 
    driver.findElement(By.xpath(xpath)).click(); 
    System.out.println("clicked"); 
} 

@DataProvider(name="bhaskar") 
public String[] dp() { 
    String[] a=new String[] {"","w3schools.com/","openurl","common" }; 
    return a; 
}
4

1 回答 1

1

出于某种原因,TestNG 并不总是为来自配置方法(例如@BeforeTest)的未处理异常打印堆栈跟踪。尝试将配置方法中的代码包装在 try-catch 中并自己打印堆栈跟踪,或者尝试调试和/或将日志记录添加到配置方法中。

于 2016-05-26T13:17:51.877 回答