0

エクステント レポート バージョン - 3.0 言語 - Java および TestNG クラス

私はクラスを持っています - ExtentManager.java

    package framewrk;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;

public class ExtentManager {

    private static ExtentReports extent;
    private static ExtentTest test;
    private static ExtentHtmlReporter htmlReporter;
    private static String filePath = "./extentreport.html";

    public static ExtentReports GetExtent(){
        extent = new ExtentReports();

        htmlReporter = new ExtentHtmlReporter(filePath);

        // make the charts visible on report open
        htmlReporter.config().setChartVisibilityOnOpen(true);

        // report title
        String documentTitle = prop.getProperty("documentTitle", "aventstack - Extent");
        htmlReporter.config().setDocumentTitle(documentTitle);
}

    public static ExtentTest createTest(String name, String description){
        test = extent.createTest(name, description);
        return test;
    }

    public static ExtentTest createTest(String name){
        test = extent.createTest(name, "");
        return test;
    }
}

および次の 2 つの testNG クラス TC1.java

package framewrk;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;

public class TC1 {
    static ExtentReports extent;
    static ExtentTest test;

    @BeforeClass
    public void setup(){
        extent = ExtentManager.GetExtent();
    }

    @Test
    public void OpenUT(){
        test = extent.createTest("Testing how fail works");
        test.log(Status.INFO, "fail check started");
        test.fail("Test fail");
    }

    @AfterClass
    public void tear()
    {
        extent.flush();
    }
}

TC2.java

package framewrk;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;

public class TC2 {
    static ExtentReports extent;
    static ExtentTest test;

    @BeforeClass
    public void setup(){
    extent = ExtentManager.GetExtent();
    }

    @Test
    public void OpenUT(){
        test = extent.createTest("Testing how pass works");
        test.log(Status.INFO, "pass check started");
        test.pass("Passed");
    }

    @AfterClass
    public void tear()
    {
        extent.flush();
    }
}

これら 2 つのテスト ケースを実行すると、最後のテストケースの結果のみが得られます。最初のテストケースの結果は、エクステント レポートに表示されません。範囲レポート 3.0 には追加パラメーターがないことに注意してください。エクステント レポートですべてのテスト ケースの結果を取得する方法は?

最後のテスト ケースの結果のみが表示され、すべてのテスト結果を取得する方法

4

4 に答える 4