Home
Analytics
Junit test for reports
moflopes
Hello!
I'd like to pick your brains about running a report as a junit test case. If anyone has done it before or has basic tips (such as sample code) on how to create a junit test for a report from scratch, I'd appreciate it! Thank you.
Find more posts tagged with
Comments
mcremer
<blockquote class='ipsBlockquote' data-author="'moflopes'" data-cid="81278" data-time="1312832012" data-date="08 August 2011 - 12:33 PM"><p>
Hello!<br />
<br />
I'd like to pick your brains about running a report as a junit test case. If anyone has done it before or has basic tips (such as sample code) on how to create a junit test for a report from scratch, I'd appreciate it! Thank you.<br /></p></blockquote>
<br />
In what sense do you want to automate a Report test?<br />
<br />
There certain components you can theoretically could auto mate and read out of the XML that makes part of the report. But you would need to wrap around the whole rendering engine to test sertain parts.<br />
<br />
So my question stand what do you wnat to test with Junit?
moflopes
We are looking to run an automated test with Junit that would insert a data mass and then compare the contents of a generated report (such as fields in a table).
mcremer
<blockquote class='ipsBlockquote' data-author="'moflopes'" data-cid="81481" data-time="1313072865" data-date="11 August 2011 - 07:27 AM"><p>
We are looking to run an automated test with Junit that would insert a data mass and then compare the contents of a generated report (such as fields in a table).<br /></p></blockquote>
<br />
Pfew what your asking is quite complex.<br />
<br />
You see you could wrap around the BIRD engine to see how things happen.<br />
<br />
But what your asking is way more complex.<br />
<br />
You want to validate output.<br />
<br />
The output of a BIRT report can be set to a lot. So for the simpleness of things let say you want to use .RPTDOCUMENT as output. This is an XML file that is renderd by the BIRT viewer to a HTML page.<br />
<br />
For this you need to map the whole ROM documentation (<a class='bbc_url' href='
http://www.eclipse.org/birt/ref/rom/index.html'>http://www.eclipse.org/birt/ref/rom/index.html</a>).<br
/>
<br />
Then you need to inject parts of in the .rptdesign document (seeing that the data result set needs to be 100% the same witch is a bit difficult because the whole idea is of a BIRT report is that the Data Set is dynamic and the report adjust to that (page break etc. natural page break forced page break etc.).<br />
<br />
Also the web viewer doesn't really stick to paper size (it sticks to the page break interval (why we have a difference between a page break and a natural page break (when it just doesn't fit on a piece of paper).<br />
<br />
So no a whole automated test. I think is not so easely done trough JUnit.<br />
<br />
I do think you can do partaly a automated test.<br />
<br />
Eg, on elements like the Data Source and Data Sets (these are testable becouse the first is just for example a jdbc conection to a database. And the second is a query and if you set the query to a database that NEVER changes the size and result set should always be the same.<br />
<br />
But thats just my opinion. If you can make it work I am interested but as far as technology wise JUnit is not the solution. It would be better to make your own JUnit standert (not Java) but BIRDunit. Where you create rules for element types that have to fit 2. (but you sort of controll this already trough Styles, Masterpage etc (witch most of us put in Library's for centrelised control).