HTML test output?

M

Mark Slater

The other thing I've been looking for is a way to output the Ruby
unit test results to the console and to an XML log file. I found a
reference to the test-report gem, but it seems to have gone away. Has
something taken its place and I've just been unable to find it? Or am
I stuck writing my own?

Thanks again,

Mark
 
V

vasudevram

The other thing I've been looking for is a way to output the Ruby
unit test results to the console and to an XML log file. I found a
reference to the test-report gem, but it seems to have gone away. Has
something taken its place and I've just been unable to find it? Or am
I stuck writing my own?

Thanks again,

Mark

Don't get what you mean by an "XML log file" - and why XML? for
further parsing of the log results?
Anyway, if on Linux, getting the output both on the console and in a
file (as long as the format wanted in both is the same) is easy:

your_test_command | tee log_filename

That uses the Linux tee command (nice name, huh?) to make a copy of
its input both on stdout and to the given filename.

And if you're on Windows and need it badly enough, install Cygwin to
be able to use tee there too.
Note: Cygwin may be a little unstable (as per what I've heard from
friends) and _may_ (I don't say will) crash in some way. Caveat
user ...

Vasudev Ram
Dancing Bison Enterprises
Biz site: http://www.dancingbison.com
PDF creation/construction toolkit:
http://sourceforge.net/projects/xtopdf
Blog: http://jugad.livejournal.com
 
M

Mark Slater

Well, with JUnit (and even PHPUnit) an XML log file is produced by
the unit tests. There are a few xsl and xslt stylesheets that can
convert those XML logs to HTML pages. That's what we use to see the
results of our automated builds. They're also easy to grep for
failures and errors. Our overall build process is driven by Ant and
Cygwin isn't an option for us; I'll ask our build guy if the "tee"
command is a viable approach for the automated builds though (all on
UNIX).

Still, an XML log file would be helpful. They're also good for QA
organizations trying to track breakages and bugs over time.

Mark
 
J

Jano Svitok

Well, with JUnit (and even PHPUnit) an XML log file is produced by
the unit tests. There are a few xsl and xslt stylesheets that can

Search the archive for 'test unit xml' and you'll find several solutions.

J.
 
M

Matt Berney

Mark said:
Well, with JUnit (and even PHPUnit) an XML log file is produced by
the unit tests. There are a few xsl and xslt stylesheets that can
convert those XML logs to HTML pages. That's what we use to see the
results of our automated builds. They're also easy to grep for
failures and errors. Our overall build process is driven by Ant and
Cygwin isn't an option for us; I'll ask our build guy if the "tee"
command is a viable approach for the automated builds though (all on
UNIX).

Still, an XML log file would be helpful. They're also good for QA
organizations trying to track breakages and bugs over time.

Mark

I have successfully generated the XML file with ci-reporter. However, I
am interested in the xsl and xslt stylesheets that convert XML logs to
HTML. How does that work?
 
M

Matt Berney

With some googling and tinkering, I figured out how to write a xslt
stylesheet for test reporting. Here is the stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="testsuite">
<h2>Test Report:<xsl:value-of select="@name"/></h2>
<table border="0">
<tr>
<td><b>Number of Tests:</b></td>
<td><xsl:value-of select="@tests"/></td>
</tr>
<tr>
<td><b>Number of Failures:</b></td>
<td><xsl:value-of select="@failures"/></td>
</tr>
<tr>
<td><b>Execution Time:</b></td>
<td><xsl:value-of select="@time"/></td>
</tr>
<tr>
<td><b>Number of Tests:</b></td>
<td><xsl:value-of select="@tests"/></td>
</tr>
</table>
<h3>Test Status</h3>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Name</th>
<th align="left">Status</th>
<th align="left">Execution Time</th>
</tr>
<xsl:apply-templates select="testcase"/>
</table>
</xsl:template>

<xsl:template match="testcase">
<tr>
<td><xsl:value-of select="@name"/></td>
<xsl:variable name="bgcolor">
<xsl:choose>
<xsl:when test="@status='Failed'">red</xsl:when>
<xsl:eek:therwise></xsl:eek:therwise>
</xsl:choose>
</xsl:variable>
<td bgcolor="{$bgcolor}"><xsl:value-of select="@status"/></td>
<td><xsl:value-of select="@time"/></td>
</tr>
<xsl:apply-templates select="failure"/>
</xsl:template>

<xsl:template match="failure">
<tr><td colspan="3"><xsl:value-of select="."/></td></tr>
</xsl:template>
</xsl:stylesheet>
 
M

Mark Slater

Awesome Matt, thanks! I'll try it out once I get the ci-reporter
installed. I got pulled away on other things for the past week and am
just now getting back to looking at this.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,318
Members
48,002
Latest member
EttaPfeffe

Latest Threads

Top