不会生成Leanft自定义框架HTML报告

时间:2017-07-29 07:55:09

标签: java selenium report leanft

下面是我的SAMPLE代码,其中我尝试使用Leanft创建一个简单的报告,我在其中获得结果xml文件。

@Test
public void Google() throws Exception {
 Reporter.init();
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.google.com");
    Thread.sleep(4000);
   if( driver.getTitle().equalsIgnoreCase("google")){
       Reporter.reportEvent("test", "test",Status.Failed);
   }
Reporter.generateReport();
driver.quit();
} 

2 个答案:

答案 0 :(得分:0)

我发现您的代码没有任何问题,因为报告也会按照您的说法生成。

但是,我相信你想要更像这样的东西来表明它在找到谷歌标题时会失败:

@Test
public void Google() throws Exception {
    Reporter.init();
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.google.com");
    Thread.sleep(4000);
    if( driver.getTitle().equalsIgnoreCase("google")){
        Reporter.reportEvent("test", "test",Status.Passed);
    } else {
        Reporter.reportEvent("test","test",Status.Failed);
    }
    Reporter.generateReport();
    driver.quit();
}

答案 1 :(得分:0)

As specified in the docs,如果您要使用自定义框架,则还需要初始化SDK(SDK.init()SDK.cleanup()

E.G。

public static void main(String [] args){
    // initialize the SDK and report only once per process
    try{
        ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
        config.setServerAddress(new URI("ws://myServerAddress:5095"));
        SDK.init(config);
        Reporter.init();

        //put your test code here.

        //Generate the report and cleanup the SDK usage.
        Reporter.generateReport();
        SDK.cleanup();
    }  catch(Exception e){
    }
}