TestNG Report / JunitReport / PDF Report

1,103 views
Skip to first unread message

dbaum

unread,
Aug 15, 2007, 8:02:58 AM8/15/07
to testng...@googlegroups.com
Hi everybody,

I'm trying to have a extensive Report on my TestNG Test in best case with snapshots of Browser prompt and converted in a pdf-file.

According to this post: http://forums.opensymphony.com/thread.jspa?messageID=39474&#39474
I tried the ant-structure:
<junitreport todir="testNGJunitReport">
<fileset dir="testoutput">
<include name="*.xml"/>
<exclude name="testng-failures.xml"/>
</fileset>
<report format="noframes" todir="testNGJunitReport"/>
</junitreport>
and afterwards I use:
<junitpdfreport todir="." styledir="default">
<fileset dir="testNGJunitReport">
<include name="*.xml"/>
</fileset>
</junitpdfreport>

unfortunately the Reports are not in a Junit-Format? Am I missing something? I also tried the explicit use of JunitXMLReporter in my testng ant task:
<reporter classname="org.testng.reporters.JUnitXMLReporter">
</reporter>

Is there somewhere a mistake? It still doesn't work? (in the xml report are the wrong tagnames according to this structure: http://junitpdfreport.sourceforge.net/managedcontent/PdfTranslation )
do I need a special xslt to transform the testng-xml to pdf?

I also tried to mangage the whole pdf-generation within java and iText (http://www.lowagie.com/iText/) but it's complex..

Thanks
*d
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=181051#181051

Cedric Beust

unread,
Aug 15, 2007, 11:44:23 AM8/15/07
to testng...@googlegroups.com
What XML file are you looking at?

--
Cédric

dbaum

unread,
Aug 16, 2007, 6:26:38 AM8/16/07
to testng...@googlegroups.com
I'm looking at the testng-results.xml

there I have tags like:
<testng-results>
<reporter-output>
<line>Start</line>
</reporter-output>
<suite name="Test">
<test name="CRUD">
<class name="Test">
...
</class>
...
</class>
</test>
</suite>
</testng-results>

do I have to use another xml?

thanks


*d
---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=181525#181525

Cosmin Marginean

unread,
Aug 16, 2007, 7:24:38 AM8/16/07
to testng...@googlegroups.com
Hello,

This is not the JUnit-compatible XML. It is a TestNG specific output. I am not a JUnit expert on this side but AFAIK the junit xml files look something like:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="util" failures="0" tests="3" time="3.905" errors="0">
  <properties/>
  <testcase name="testAdd" time="0.01" classname="..."/>
  <testcase name="testDecodeBase64" time="0.01" classname="..."/>
  <testcase name="testGetIcon" time="0.1" classname="..."/>
</testsuite>


My bests,
Cosmin

dbaum

unread,
Aug 16, 2007, 7:49:42 AM8/16/07
to testng...@googlegroups.com
Hi Cosmin,

thats what I guess to, but why is a compatibility said in this thread?:
http://forums.opensymphony.com/thread.jspa?messageID=39474&#39474

I'm really confused, I thought TestNG Reports are compatible to Junit Reports? or at least there is a Transformer?

thanks
*d
---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=181544#181544

Cosmin Marginean

unread,
Aug 16, 2007, 7:54:08 AM8/16/07
to testng...@googlegroups.com
Hello,


On 8/16/07, dbaum <testng...@opensymphony.com> wrote:

Hi Cosmin,

thats what I guess to, but why is a compatibility said in this thread?:
http://forums.opensymphony.com/thread.jspa?messageID=39474&#39474

This is true. What I meant is that the file you are looking at is not the correct one.

I'm really confused, I thought TestNG Reports are compatible to Junit Reports? or at least there is a Transformer?

TestNG has both compaible and not-compatible JUnit reports. I am not sure about the naming of the JUnit-compatible reports, but I believe that they should be somewhere in the test-output folder (or in one of it's subfolders).

Steve Loughran

unread,
Aug 16, 2007, 8:27:05 AM8/16/07
to testng...@googlegroups.com
On 16/08/07, Cosmin Marginean <cosm...@gmail.com> wrote:
> Hello,
>
>
> On 8/16/07, dbaum <testng...@opensymphony.com> wrote:
> >
> > Hi Cosmin,
> >
> > thats what I guess to, but why is a compatibility said in this thread?:
> >
> http://forums.opensymphony.com/thread.jspa?messageID=39474&#39474
>
> This is true. What I meant is that the file you are looking at is not the
> correct one.
>
> > I'm really confused, I thought TestNG Reports are compatible to Junit
> Reports? or at least there is a Transformer?
>
> TestNG has both compaible and not-compatible JUnit reports. I am not sure
> about the naming of the JUnit-compatible reports, but I believe that they
> should be somewhere in the test-output folder (or in one of it's
> subfolders).

look for files with names like TEST-*.xml, eg.

TEST-org.smartfrog.test.system.assertions.AssertionsTest.xml

the root tag should be testsuite:

<?xml version="1.0" encoding="UTF-8" ?>

<testsuite errors="0" failures="0" hostname="chamonix"
name="org.smartfrog.test.system.assertions.AssertionsTest" tests="13"
time="16.299" timestamp="2007-08-15T12:01:14">

dbaum

unread,
Aug 16, 2007, 9:05:33 AM8/16/07
to testng...@googlegroups.com
I did find the junit compatible files, they are in the folder which has the name of the suite and the xml-files do have the name of the several test one has.

means if one has a xmlfileset like this:
<suite name="Suitename" verbose="1" >
<test name="Testname">...

the compatible file is [Suitename]/Testname.xml
and for every test there is a xml-file. (depends on fileFragmentationLevel i guess)

thanks for helping me with this.

another question:
If I use those files I loose my Reporter.logs where I'm depending on. Maybe the reporting in TestNG isn't fully developed yet. There is no possibility to get more information in the reports than the method-names? (I know normaly Junit is responsible for this)
Is there a possibility to have more Informations in the Reports, like for example assert-outputs and I didn't find yet?

@ Cosmin
I did have a look at your post " XSLT for the XML Reporter", good work!
are you planning to generate a xslt converting the testng-xml output to an pdf? would be great ;-)
the xsl for junit reports can be found in junitpdfreport_essentials:
http://sourceforge.net/project/showfiles.php?group_id=153965&package_id=170893&release_id=375934

So, if somebody has any idea to have a detailed report in pdf I would be really glad hearing..

Thanks


*d
---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=181565#181565

Cosmin Marginean

unread,
Aug 16, 2007, 9:51:02 AM8/16/07
to testng...@googlegroups.com
Hello,

I believe there is a slight misunderstanding here.

TestNG has several reporting mechanism among which:
 - the JUnit report (for which I believe you could find a PDF converter)
 - the TestNG specific XML report which has nothing to do with JUnit (for which I provided the XSL that you mentioned - thanks for your comments on this). This XML report contains a lot more TestNG info than the JUnit compatible one, but the "user friendly output" for this is in development (by this I mean the XSL who's output you've seen). Creating an XSL that transforms an XML to PDF is something that (AFAIK) cannot be achieved with most "conventional weapons". I believe there are however tools like Jasper that can help you with PDFs (for both JUnit and TestNG reports).
fileFragmentationLevel has nothing to do with JUnit reports and it is noly related to the TestNG-specific XML report.

As an alternative, you could check out this article: http://www.javaworld.com/javaworld/jw-04-2005/jw-0404-testng.html
I explains (among other issues) about the generation of a PDF report using iText.

Hope this helps.
My bests,
Cosmin


On 8/16/07, dbaum <testng...@opensymphony.com> wrote:

Cedric Beust

unread,
Aug 16, 2007, 10:02:18 AM8/16/07
to testng...@googlegroups.com
On 8/16/07, dbaum <testng...@opensymphony.com> wrote:

another question:
If I use those files I loose my Reporter.logs where I'm depending on. Maybe the reporting in TestNG isn't fully developed yet. There is no possibility to get more information in the reports than the method-names? (I know normaly Junit is responsible for this)

Are you talking about the JUnitReport XML files?

These files are JUnit-specific, and therefore, they can't contain anything that TestNG-specific.

You will find your Reporter outputs in both the HTML and the TestNG-specific XML file that get generated, though...

Does this answer your question?

 

Is there a possibility to have more Informations in the Reports, like for example assert-outputs and I didn't find yet?

@ Cosmin
I did have a look at your post " XSLT for the XML Reporter", good work!
are you planning to generate a xslt converting the testng-xml output to an pdf? would be great ;-)

FYI, we already have a PDF generator, except that it was written in Java (I forget its name but I'll look it up as soon as I'm back at my desk, if you're interested in using it).

--
Cédric

dbaum

unread,
Aug 16, 2007, 10:39:15 AM8/16/07
to testng...@googlegroups.com
ok maybe there is a litte of misunderstanding..

@Cosmin
>Creating an XSL thattransforms an XML to PDF is something that (AFAIK) cannot be

>achieved with most "conventional weapons".

within junitpdfreport they use xsl to transfrom the junit-xml files into pdf (AFAIK) I thougth maybe there is a testNGpdfreport tool, normally only the xsl needs to be changed?

>As an alternative, you could check out this article:
>http://www.javaworld.com/javaworld/jw-04-2005/jw-0404-testng.html

Thanks a lot for this information, unfortunately the code used in this articel is from a older version of TestNG, but I will try to adapt..

@Cédric

>Are you talking about the JUnitReport XML files?
>These files are JUnit-specific, and therefore, they can't contain anything
>that TestNG-specific.
>You will find your Reporter outputs in both the HTML and the TestNG-specific
>XML file that get generated, though...
>Does this answer your question?

maybe I mixed up two things..

1) The Junit Reports generated out of TestNG. Within the Junit-Report structur there is a tag called <system-out>, so why does't the JunitXMLReporter has a possibility to print the Reporter logs to those <system-out> tags?

2)TestNG Reports itself. Is there a possibility to report something other than the method-name and the Reporter output? Something like assert-Methods also doing a kind of reporting?like this:

MyTestmethod
Assert 1 equals 1 is true
Assert Text "a" equals "a" is true
Show all outputs
myReporteroutput is here...

Thanks again! yes I guess my question has been answered, but still it would be nice if one has ideas about doing detailed reports at best within a pdf Report out of TestNG.

*d
---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=181602#181602

Cosmin Marginean

unread,
Aug 16, 2007, 11:08:55 AM8/16/07
to testng...@googlegroups.com
On 8/16/07, dbaum <testng...@opensymphony.com> wrote:

ok maybe there is a litte of misunderstanding..

@Cosmin
>Creating an XSL thattransforms an XML to PDF is something that (AFAIK) cannot be
>achieved with most "conventional weapons".
within junitpdfreport they use xsl to transfrom the junit-xml files into pdf (AFAIK) I thougth maybe there is a testNGpdfreport tool, normally only the xsl needs to be changed?

I am not sure I understand this. The TestNG PDF is a plugin that I assume is related to the link I sent you but I don't thinks is in any way related to any XSL. Generating a PDF with and XSL is something that (AFAIK) depends on some implementations of some w3c specs (FO), or that can be done with tools like Jasper (I think). You will have to dig for this yourself. 

>As an alternative, you could check out this article:
> http://www.javaworld.com/javaworld/jw-04-2005/jw-0404-testng.html
Thanks a lot for this information, unfortunately the code used in this articel is from a older version of TestNG, but I will try to adapt..

@CÃ(c)dric
>Are you talking about the JUnitReport XML files?
>These files are JUnit-specific, and therefore, they can't contain anything
>that TestNG-specific.
>You will find your Reporter outputs in both the HTML and the TestNG-specific
>XML file that get generated, though...
>Does this answer your question?

maybe I mixed up two things..

1) The Junit Reports generated out of TestNG. Within the Junit-Report structur there is a tag called <system-out>, so why does't the JunitXMLReporter has a possibility to print the Reporter logs to those <system-out> tags?

2)TestNG Reports itself. Is there a possibility to report something other than the method-name and the Reporter output? Something like assert-Methods also doing a kind of reporting?like this:

MyTestmethod
Assert 1 equals 1 is true
Assert Text "a" equals "a" is true
Show all outputs
myReporteroutput is here...

You can user org.testng.Reporter.log() into your test code in order to generate reporter output. This can be obtained for sure with the TestNG-specific XML report, but I don't know if it can be obtained with the JUnit-compatible XML. 

Cosmin Marginean

unread,
Aug 16, 2007, 9:32:55 AM8/16/07
to testng...@googlegroups.com
Hello,

I believe there is a slight misunderstanding here.

TestNG has several reporting mechanism among which:
 - the JUnit report (for which I believe you could find a PDF converter)
 - the TestNG specific XML report which has nothing to do with JUnit (for which I provided the XSL that you mentioned - thanks for your comments on this). This XML report contains a lot more TestNG info than the JUnit compatible one, but the "user friendly output" for this is in development (by this I mean the XSL who's output you've seen). Creating an XSL that transforms an XML to PDF is something that (AFAIK) cannot be achieved with most "conventional weapons". I believe there are however tools like Jasper that can help you with PDFs (for both JUnit and TestNG reports).
fileFragmentationLevel has nothing to do with JUnit reports and it is noly related to the TestNG-specific XML report.

As an alternative, you could check out this article: http://www.javaworld.com/javaworld/jw-04-2005/jw-0404-testng.html
I explains (among other issues) about the generation of a PDF report using iText.

Hope this helps.
My bests,
Cosmin

Cosmin Marginean

unread,
Aug 16, 2007, 10:58:03 AM8/16/07
to testng...@googlegroups.com

ok maybe there is a litte of misunderstanding..

@Cosmin 
  
Creating an XSL thattransforms an XML to PDF is something that (AFAIK) cannot be 
achieved with most "conventional weapons". 
    
within junitpdfreport they use xsl to transfrom the junit-xml files into pdf (AFAIK) I thougth maybe there is a testNGpdfreport tool, normally only the xsl needs to be changed?

  
I am not sure I understand this. The TestNG PDF is a plugin that I assume is related to the link I sent you but I don't thinks is in any way related to any XSL. Generating a PDF with and XSL is something that (AFAIK) depends on some implementations of some w3c specs (FO), or that can be done with tools like Jasper (I think). You will have to dig for this yourself.

  
As an alternative, you could check out this article:
http://www.javaworld.com/javaworld/jw-04-2005/jw-0404-testng.html
    
Thanks a lot for this information, unfortunately the code used in this articel is from a older version of TestNG, but I will try to adapt..

@CÃ(c)dric 
  
Are you talking about the JUnitReport XML files?
These files are JUnit-specific, and therefore, they can't contain anything
that TestNG-specific.
You will find your Reporter outputs in both the HTML and the TestNG-specific
XML file that get generated, though...
Does this answer your question? 
    
maybe I mixed up two things..

1) The Junit Reports generated out of TestNG. Within the Junit-Report structur there is a tag called <system-out>, so why does't the JunitXMLReporter has a possibility to print the Reporter logs to those <system-out> tags?

2)TestNG Reports itself. Is there a possibility to report something other than the method-name and the Reporter output? Something like assert-Methods also doing a kind of reporting?like this:

MyTestmethod
Assert 1 equals 1 is true
Assert Text "a" equals "a" is true
Show all outputs
myReporteroutput is here...

  
You can user org.testng.Reporter.log() into your test code in order to generate reporter output. This can be obtained for sure with the TestNG-specific XML report, but I don't know if it can be obtained with the JUnit-compatible XML.

Cédric Beust ♔

unread,
Aug 16, 2007, 11:53:11 AM8/16/07
to testng...@googlegroups.com
On 8/16/07, dbaum <testng...@opensymphony.com> wrote:

1) The Junit Reports generated out of TestNG. Within the Junit-Report structur there is a tag called <system-out>, so why does't the JunitXMLReporter has a possibility to print the Reporter logs to those <system-out> tags?

Probably because the JUnitReport reporter was written a long time ago, and more as a proof of concept than a fully blown listener.  It would probably be trivial to add Reporter support as you suggest.

Would you be interested in adding this support?  The class you are looking for is org.testng.reporters.JUnitXMLReporter...

As for PDF, Thierry Janaudy once wrote a PDF generator, which he described in this article...

--
Cédric

Steve Loughran

unread,
Aug 16, 2007, 4:03:22 PM8/16/07
to testng...@googlegroups.com
On 16/08/07, Cedric Beust <cbe...@google.com> wrote:
>
>
> On 8/16/07, dbaum <testng...@opensymphony.com> wrote:
> >
> > another question:
> > If I use those files I loose my Reporter.logs where I'm depending on.
> Maybe the reporting in TestNG isn't fully developed yet. There is no
> possibility to get more information in the reports than the method-names? (I
> know normaly Junit is responsible for this)
>
> Are you talking about the JUnitReport XML files?
>
> These files are JUnit-specific, and therefore, they can't contain anything
> that TestNG-specific.


Let's be precise. They are Ant specific, not Junit-specific. The Ant
team grew them over time and added things we needed (like wall time
and host) because we saw the need for them.

- There's no specific reason why they should be JUnit only
- our own AntUnit test tool generates stuff in the format too.
- we know some of the limitations.
-Single host log; loss of level info from the logging apis
-non-progressive output; very brittle to JVM crash
-no scope for skipped tests
-no place for descriptions
-unable to scale to the problem of reporting the same test running
on 30 machines/system configurations, where partial failures are a
common outcome

I'd like to fix these, and I have the Ant commit rights to do so. But
we've accidentally created a reporting format that gets used
everywhere, so we have to be very carefull about extending it gently.

I'd like to set up a working group to extend the existing format some
time in september onwards, if you are interested. No 'version 2.0'
effects ('lets redo it all in RDF'), just simple additions to the
existing XML that doesnt break the current set of post-processors.

-steve

dbaum

unread,
Aug 17, 2007, 8:25:22 AM8/17/07
to testng...@googlegroups.com
HI Cedric,

I tried to extend the JUnitXMLReporter so that the log of TestNg Reporter is available for <system-out> tags in Junit Reports. It all works fine but in the end the task mentioned above to create HTML out of JunitReports did ignore the <system-out> tags (also when not whith CDATA). So if anybody knows if and how <system-out>-tags are made avaialbe in HTML Reports give a sign.

I used this structure:
<testsuite name="a" failures="0" tests="3" time="0.0" errors="0">
<properties/>
<testcase name="ab" time="0.016"></testcase>
<system-out><![CDATA[runTesthello]]></system-out>
<system-err></system-err>
</testsuite>

I'm also trying to create an PDFReporter for TestNG, just adapting the one mentioned above.. Iguess this will be the promising alternative..

*d
---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=182077#182077

Nik

unread,
Aug 21, 2007, 2:31:34 AM8/21/07
to testng-users
Hi dbaum,

<code>

<target name="report" description="generate reports using junireport">
<junitreport todir="${test.report}">
<fileset dir="${test.output}">
<include name="**/*.xml" />
</fileset>
<report format="noframes" todir="${test.report}" />
</junitreport>
</target>

</code>

You can found one folder having name of your suite in test.output
directory.

In your case there may be Test dire having CRUD.xml and other xml
depending upon the your test names.

JUnitReports are construct using this xml's. So I prefer to use **/
*.xml so it will search in sub folder also.

You may find following structure :

test.output
|
|---------------------------------------- <Suite Name>
emailable-report.html |
index.html |
testng.css |
testng-failed.xml |
testng-results.xml |
|
<TestName>.properties
<TestName>.xml
{This file is needed for generating JUnitReports}
testng-failed.xml

I hope you that you might solve this problem but I posted this so that
any other person may get benefited.

./Nikhil

On Aug 15, 5:02 pm, dbaum <testng-us...@opensymphony.com> wrote:
> Hi everybody,
>
> I'm trying to have a extensive Report on my TestNG Test in best case with snapshots of Browser prompt and converted in a pdf-file.
>

> According to this post:http://forums.opensymphony.com/thread.jspa?messageID=39474


> I tried the ant-structure:
> <junitreport todir="testNGJunitReport">
> <fileset dir="testoutput">
> <include name="*.xml"/>
> <exclude name="testng-failures.xml"/>
> </fileset>
> <report format="noframes" todir="testNGJunitReport"/>
> </junitreport>
> and afterwards I use:
> <junitpdfreport todir="." styledir="default">
> <fileset dir="testNGJunitReport">
> <include name="*.xml"/>
> </fileset>
> </junitpdfreport>
>
> unfortunately the Reports are not in a Junit-Format? Am I missing something? I also tried the explicit use of JunitXMLReporter in my testng ant task:
> <reporter classname="org.testng.reporters.JUnitXMLReporter">
> </reporter>
>
> Is there somewhere a mistake? It still doesn't work? (in the xml report are the wrong tagnames according to this structure:http://junitpdfreport.sourceforge.net/managedcontent/PdfTranslation)
> do I need a special xslt to transform the testng-xml to pdf?
>
> I also tried to mangage the whole pdf-generation within java and iText (http://www.lowagie.com/iText/) but it's complex..
>
> Thanks
> *d
> ---------------------------------------------------------------------

> Posted via Jive Forumshttp://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=...

jancumps

unread,
Dec 16, 2007, 5:24:02 PM12/16/07
to testng...@googlegroups.com
The default formatter of the JUnitPDFReport task shows System.err and System.out.

Regards, Jan


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=111185&messageID=257292#257292

Reply all
Reply to author
Forward
0 new messages