0

2.4 リリース バージョンを使用して、完全なテスト結果をエクステント レポートにプッシュするのに問題があります。基本的に、各クラス ファイルに 2 つのテスト 1 つのテストがあり、基本レポーターとして "SimpleReportFactory" があります。

testng.xml を介してテストを実行すると、最後のテストのみがキャプチャされます。この問題の解決を手伝ってください。他の投稿を確認しました。いくつかの回答が見つかりましたが、適用に失敗しました。エクステント レポート インスタンスを使用してテスト全体で使用し、すべてのテストに対して 1 つのレポートを生成できる実際の例が必要です。

フレームワークベースのテストであるtestng xmlを介して以下のテストを実行すると、2番目のテストクラスでnullポインター例外が発生します! これは、私が見つけた投稿の1つです(ExtentReport に2つのクラスの結果を追加できませんでした)。ここで、与えられた提案を実装しようとしましたが、NPEが与えられました! インスタンスを実装してグローバルに使用する方法がわからない。

    public class SimpleReportFactory {

    public static ExtentReports reporter;

    public static synchronized ExtentReports getReporter () {
        if (reporter == null) {
            reporter = new ExtentReports("SimpleReport.html", true, DisplayOrder.NEWEST_FIRST);
        }
        return reporter;
    }

    public static synchronized void closeReporter() {
        reporter.flush();
        reporter.close();
    }

}

    public class Registration extends BaseClass {


    public ExtentReports reporter = SimpleReportFactory.getReporter();


    @BeforeMethod
    public void setUp() throws IOException {
        intialize();


    }


    @Test
    public void TestUserRegistration() throws Exception {

        ExtentTest testreporter = reporter.startTest("TestUserRegistration");


        WebElement ProfileLink = getWebElement("profilepage.createaccount.profilelink");
        ProfileLink.click();
        testreporter.log(LogStatus.INFO, " Click on the Profile Link from HomePage");


        RandomEmail();
        driverwait(1);
        WebElement Password = getWebElement("profilepage.createaccount.password");
        Password.sendKeys(Repository.getProperty("password"));
        driverwait(1);
        WebElement SubmitButton = getWebElement("profilepage.createaccount.submitbutton");
        SubmitButton.click();
        reporter.endTest(testreporter);


    }

    @AfterMethod
    public void testDown() {
        CloseBrowser();
        reporter.close();


   }

}

    public class SignIn extends BaseClass {

    ExtentReports reporter;

    @BeforeMethod
    public void setUp() throws IOException {
        intialize();

    }

    @Test
    public void LoginToTheApplication() throws Exception {

        ExtentTest testreporter = reporter.startTest("LoginToTheApplication");

        WebElement profilelink = getWebElement("profilepage.signin.profilelink");
        profilelink.click();
        testreporter.log(LogStatus.INFO, "Hey");

        WebElement signinemail = getWebElement("profilepage.signin.emailaddress");
        signinemail.sendKeys(Repository.getProperty("signinemailaddress"));

        driverwait(1);

        WebElement signinpassword = getWebElement("profilepage.signin.password");
        signinpassword.sendKeys(Repository.getProperty("signinpassword"));

        driverwait(1);

        WebElement clicksubmit = getWebElement("profilepage.signin.submitbutton");
        clicksubmit.click();
        reporter.endTest(testreporter);

    }

    @AfterMethod
    public void testDown() {

    CloseBrowser();
    reporter.close();
}
4

1 に答える 1