Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs from TestNG DataProvider methods are captured and associated with the corresponding test in ReportPortal. #202

Open
akshayamaldhure opened this issue Aug 30, 2023 · 8 comments
Assignees

Comments

@akshayamaldhure
Copy link

I understand that the logs from the various hooks (like all the methods annotated with @Before* and @After*) and all the @Tests are available for viewing in Reportportal. However, I did not see those coming from the methods annotated with @DataProvider. This makes it a bit challenging to debug any issues related to construction/population of the test data. Please let me know if I'm missing anything here.

@DzmitryHumianiuk
Copy link
Member

@HardNorth looks like another good thing to consider.
I'm not sure if we report this level of logs anyhow right now.

@HardNorth
Copy link
Member

@DzmitryHumianiuk I doubt this is really possible. Data providers are called before test creation. So the only option is launch logs, where, I believe, it is already reported.

@DzmitryHumianiuk
Copy link
Member

@akshayamaldhure look if you can see them in Launch's Log view:
blue icon in a line with List view -> Unique Errors -> Log VIew

image

@akshayamaldhure
Copy link
Author

@DzmitryHumianiuk Apologies for the delayed response. I do not see the logs from my @DataProvider annotated method under Log View either. The logs logged using the same logger from other methods (like the ones annotated with @Test are visible in Reportportal).

Screenshot 2023-11-01 at 2 42 08 PM

@DzmitryHumianiuk
Copy link
Member

@akshayamaldhure, in that case, it looks like we need to implement this on the agent side of the ReportPortal integration to properly capture these log types.
As @HardNorth mentioned, since the data provider initializes before the actual test case, we don't have an active test case ID to tie the logs to.

We'll need to develop a mechanism that allows us to link logs to a test case that hasn’t been created yet. This could potentially be managed with a promise object that anticipates the expected ID, or by pre-determining the test case ID before its initialization.

So, to give you a straightforward answer: this functionality isn't currently available.

@DzmitryHumianiuk
Copy link
Member

@akshayamaldhure, with your permission, I'll keep this request open and reclassify it as a feature request.
I'd like to hold onto it in our backlog so that sooner or later, we consider implementing it as part of our standard functionality.

@DzmitryHumianiuk DzmitryHumianiuk changed the title Question: How to view the logs from the TestNG DataProvider methods? Logs from TestNG DataProvider methods are captured and associated with the corresponding test in ReportPortal. Nov 6, 2023
@DzmitryHumianiuk DzmitryHumianiuk transferred this issue from reportportal/reportportal Nov 6, 2023
@HardNorth
Copy link
Member

@DzmitryHumianiuk What you saying is not even possible. We just simply don't have any reference on Test Case. No any "promises" would help you, because you won't chain them with currently running test, unless it's single-threaded execution.

@DzmitryHumianiuk
Copy link
Member

@HardNorth, as far as I remember from the inner workings of TestNG, the relationship between the DataProvider and the method using it is formed in a single thread. So, there shouldn't be a situation where the DataProvider runs in a separate thread.
It seems that TestNG structures the call sequence starting with the method, and if the method has a DataProvider, it adds it to the call sequence before the method. This applies to the number of threads involved.

What I mean by "promise" is essentially deferring the submission of logs related to the DataProvider until the next active test appears. When the next active test starts, we would assign its ID to the logs from the DataProvider, which are temporarily stored in a thread-safe collection.

Right now, the logs are likely generated and sent without belonging to a specific testItem and are assigned at the launch level. But if we delay them, knowing they’re from the DataProvider, and assign them to the next upcoming TestCase ID, this could be a solution.

These are my theoretical ideas — reality might differ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants