Unit testing a report definition

We configured a unit test rule for report definition.

The assertion passed in DEV env, but when we run the same test case in QA, it fails because the work table contains different case data in QA.

Per Pega best practice, how should we resolve this issue?

@Will Cho: Can you try simulation of minimum set of data required to test the variations of query results in QA?

@JayantS8 We can certainly target minimum set of test data. They however bump into the same issue occasionally. Test cases for report definition runs in one env ok but fails in another env. This is automated using Deployment Manager and hampering their deployment process. Client is looking for any best practice to streamline RD unit testing that would work commonly across different environments.

@Will Cho, you can use the Create data Object to create an instance in the DB prior to executing the report:

This should happen prior to the execution of the unit test, and then validate the created object.

@delir Thanks for the input. I just tried, and from Tracer i see that it is creating a temp work object in clipboard (but not committed to db). Then the report definition (tested rule) will be executed but this runs against the work objects in database and puts the result in pyReportContentPage, which gets validated in the assertions. From this observation, the temp work object did not serve the purpose. Am i missing anything here or appreciate any other feedback.

@Will Cho Actually, i removed the cleanup checkbox and see the work object created in DB. RD processed the new work object and ran thru an assertion. I’ll circle back to client if this is viable for them.

Cleanup.jpg

@Will Cho Today i noticed that selecting the default cleanup checkbox actually properly removes the WO created in Setup. I suggest to validate this cleanup part when anyone tries this. The bottom line is that ‘Create work object’ in Setup is a valid option to unit test report definition or any test case that needs to query in database.

I also found this article useful - How to test Activities with DB operations using PegaUnit? | Support Center