未生成 Leanft 自定义框架 HTML 报告

Leanft Custom Framework HTML reports are not generated

下面是我的示例代码,我在其中尝试使用 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();
} 

我看不出你的代码有什么问题,因为报告也按照你说的那样生成了。

但是,我相信你想要更像这样的东西来表明它在找到 Google 标题时通过:

@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();
}

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

例如

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){
    }
}