我想在范围报告(4)的每个步骤中添加详细信息,这样我就不会像它那样空着
我的代码有一个扩展区类和一个ITestListener(TestNG),所以该类看起来像这样(如下)
在哪里写测试通过,这些是现在的细节,我想要类似的东西

    public void onTestStart(ITestResult result) {
        create_test(result.getName());
    }

    @Override
    public void onTestSuccess(ITestResult result) {
        System.out.println("The success test name is: "+result.getTestName());
        test.log(test.getStatus(), "Test pass");
        try {
            test.pass(result.getTestName(),MediaEntityBuilder.createScreenCaptureFromPath(CaptureScreen()).build());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onTestFailure(ITestResult result) {
        System.out.println("The failed test name is: "+result.getName());

        try {
            test.fail(result.getTestName(), MediaEntityBuilder.createScreenCaptureFromPath(CaptureScreen()).build());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onTestSkipped(ITestResult result) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onStart(ITestContext context) {
        init();

    }

    @Override
    public void onFinish(ITestContext context) {
        extent.flush();

    } ```

and test looks like :

@Test (priority = 1 ,groups= "OpenWebSite-test")
    public void upFooterOpenWebSite() {
        MapsPage.getWebSite(siteURL);
    }

最佳答案

使用test.log(Status.INFO,"login using a valid IsoMetrix username and password");基本上,您必须在每个步骤中添加Status.INFO,它将在报告中可用。

10-02 04:33