我正在使用扩展报告版本4,我在扩展报告Java文档站点中使用了相同的代码提及,但是没有成功执行锁和代码,但最终HTML报告未生成,我们将不胜感激。

下面是代码:

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentAventReporter;
import io.github.bonigarcia.wdm.WebDriverManager;

public class Reporting {

    WebDriver driver;
    public static ExtentTest test;
    public static ExtentReports extent;

    public static void test() {

        // directory where output is to be printed
        ExtentAventReporter avent = new ExtentAventReporter(System.getProperty("user.dir") + "./reports/TestExecution.html");
        extent = new ExtentReports();
        extent.attachReporter(avent);
        test=extent.createTest("Login").assignAuthor("Rajesh");

    }

    @AfterMethod
    public void after(){
        extent.flush();
    }



    @Test
    public void testings(){

        WebDriverManager.chromedriver().setup();

        driver = new ChromeDriver();
        test();
        driver.get("http://www.google.com");


    }

}

最佳答案

代替
  extent = new ExtentReports();
采用
extent = new ExtentReports(outputDirectory + File.separator + "ExtentReportsTestNG.html", true);

07-26 09:13