如何使用AssertJ软评估为每个软声明故障获取屏幕截图

发布于 2025-01-25 20:12:24 字数 929 浏览 4 评论 0原文

我想在下面实现: -

CustomSoftAssertJ softly = new CustomSoftAssertJ();
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertAll();

我正在尝试下面,但它无法正常工作: -

public class CustomSoftAssertJ extends AbstractSoftAssertions {
    @Override
    public void onAssertionErrorCollected(AssertionError assertionError) {
        super.onAssertionErrorCollected(assertionError);
        ExtentReport.getTest().fail(assertionError.getLocalizedMessage(),
                MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
    }
}

我看到了Assertj的原始文档,但是我无法理解。 有人可以用简单的例子帮我吗?

I want to achieve below: -

CustomSoftAssertJ softly = new CustomSoftAssertJ();
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertThat(actual).isEqualTo(expected); // get screen shot on failure
softly.assertAll();

And I am trying below and it is not working: -

public class CustomSoftAssertJ extends AbstractSoftAssertions {
    @Override
    public void onAssertionErrorCollected(AssertionError assertionError) {
        super.onAssertionErrorCollected(assertionError);
        ExtentReport.getTest().fail(assertionError.getLocalizedMessage(),
                MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
    }
}

I saw the original documentation from AssertJ, However I could not get it.
Could someone help me out here with simple example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文