Hello. Thanks for the video tutorial. Is there a way for extent report to take test method name by itself automatically so I do not have to write extent parts of the code in test itself? Also to make it realise if it passed or failed?
Hey there, Yes, Extent Reports can automatically capture test method names and their execution status (pass/fail) without explicitly writing code in each test. This can be achieved by integrating Extent Reports with a test framework like TestNG or JUnit and using their listeners or annotations.
When a test is Annoteted with "@Disabled" the program generate the exception (java.lang.NullPointerException: Cannot invoke "com.aventstack.extentreports.ExtentTest.log(com.aventstack.extentreports.Status, com.aventstack.extentreports.markuputils.Markup)" because "com.xx.yy.ExecutionContext.CURRENT_EXTENT_TEST" is null at com.xx.yy..extentreports.ExtentTestListener.testDisabled(ExtentTestListener.java:13) .... and the test report fails to show correct test information. (Dashboard shows wrong information about tests status) Do you know why?
Hey there, The issue you're experiencing with @Disabled tests causing NullPointerException in your Extent Reports integration is not directly related to the version of Selenium, but rather how the test framework and your reporting setup interact. The core of the problem lies in how disabled tests are handled by your test listener and the lifecycle of ExtentTest objects within that context. Given the issue description, it seems your ExtentTestListener attempts to log a disabled test without checking if the ExtentTest instance (ExecutionContext.CURRENT_EXTENT_TEST) has been initialized, leading to a NullPointerException. This can happen because the initialization logic that typically runs before each test (e.g., in a @BeforeEach method) doesn't execute for @Disabled tests, so the ExtentTest instance remains null. To address this issue, you need to adjust your test listener to handle @Disabled tests properly. Here's a conceptual approach to solving this problem: Check for Null Before Logging: In your listener methods (e.g., testDisabled), add a null check for the ExtentTest instance before attempting to log anything. If the instance is null, you can either skip the logging for this test or initialize a new ExtentTest instance specifically for logging the disabled test. Global Initialization: Ensure that any required global initialization for your Extent Reports setup is performed outside of test-specific setup methods. This way, even if a test is skipped, the essential parts of your reporting infrastructure are ready to be used.
📌 GitHub Repo:
github.com/AutomateThePlanet/generate-extent-reports-in-selenium
Very nice and easy to follow tutorial.
Thanks for sharing.
Glad to hear the tutorial was helpful for you!
Do subscribe the channel for more such tutorials !🙂
Hello. Thanks for the video tutorial. Is there a way for extent report to take test method name by itself automatically so I do not have to write extent parts of the code in test itself? Also to make it realise if it passed or failed?
Hey there,
Yes, Extent Reports can automatically capture test method names and their execution status (pass/fail) without explicitly writing code in each test. This can be achieved by integrating Extent Reports with a test framework like TestNG or JUnit and using their listeners or annotations.
I want your help
Sure, tell me how we can assist you.
When a test is Annoteted with "@Disabled" the program generate the exception (java.lang.NullPointerException: Cannot invoke "com.aventstack.extentreports.ExtentTest.log(com.aventstack.extentreports.Status, com.aventstack.extentreports.markuputils.Markup)" because "com.xx.yy.ExecutionContext.CURRENT_EXTENT_TEST" is null
at com.xx.yy..extentreports.ExtentTestListener.testDisabled(ExtentTestListener.java:13)
....
and the test report fails to show correct test information. (Dashboard shows wrong information about tests status)
Do you know why?
Hey there,
The issue you're experiencing with @Disabled tests causing NullPointerException in your Extent Reports integration is not directly related to the version of Selenium, but rather how the test framework and your reporting setup interact. The core of the problem lies in how disabled tests are handled by your test listener and the lifecycle of ExtentTest objects within that context.
Given the issue description, it seems your ExtentTestListener attempts to log a disabled test without checking if the ExtentTest instance (ExecutionContext.CURRENT_EXTENT_TEST) has been initialized, leading to a NullPointerException. This can happen because the initialization logic that typically runs before each test (e.g., in a @BeforeEach method) doesn't execute for @Disabled tests, so the ExtentTest instance remains null.
To address this issue, you need to adjust your test listener to handle @Disabled tests properly. Here's a conceptual approach to solving this problem:
Check for Null Before Logging: In your listener methods (e.g., testDisabled), add a null check for the ExtentTest instance before attempting to log anything. If the instance is null, you can either skip the logging for this test or initialize a new ExtentTest instance specifically for logging the disabled test.
Global Initialization: Ensure that any required global initialization for your Extent Reports setup is performed outside of test-specific setup methods. This way, even if a test is skipped, the essential parts of your reporting infrastructure are ready to be used.