# HTML test output?

**URL:** <https://rubytalk.org/t/html-test-output/39747>\
**Category:** ruby-talk\
**Created:** [8 August 2007 04:20 UTC](https://rubytalk.org/t/html-test-output/39747 "2007-08-08T04:20:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Slater](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mark\_Slater](https://rubytalk.org/u/Mark_Slater)\
**Post date:** [8 August 2007 04:20 UTC](https://rubytalk.org/t/html-test-output/39747/1 "2007-08-08T04:20:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vasudevram](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vasudevram](https://rubytalk.org/u/vasudevram)\
**Post date:** [8 August 2007 16:34 UTC](https://rubytalk.org/t/html-test-output/39747/2 "2007-08-08T16:34:59Z")

</div>

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](http://www.dancingbison.com)  
PDF creation/construction toolkit:  
&nbsp;&nbsp;[Conversion of other file formats to PDF download | SourceForge.net](http://sourceforge.net/projects/xtopdf)  
Blog: [http://jugad.livejournal.com](http://jugad.livejournal.com)

> **···**
>
> On Aug 8, 9:20 am, Mark Slater \<li...@humanesoftware.com\> wrote:
> 
> > 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

---

<div class="post-metadata">

**Author:** ![Chris\_Carter](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@Chris\_Carter](https://rubytalk.org/u/Chris_Carter)\
**Post date:** [9 August 2007 18:26 UTC](https://rubytalk.org/t/html-test-output/39747/3 "2007-08-09T18:26:37Z")

</div>

Check out the ci-reporter rails plugin and gem.

> **···**
>
> On 8/7/07, Mark Slater \<lists@humanesoftware.com\> wrote:
> 
> > 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
> 
> --  
> Chris Carter  
> concentrationstudios.com  
> brynmawrcs.com

---

<div class="post-metadata">

**Author:** ![Mark\_Slater](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mark\_Slater](https://rubytalk.org/u/Mark_Slater)\
**Post date:** [8 August 2007 20:51 UTC](https://rubytalk.org/t/html-test-output/39747/4 "2007-08-08T20:51:38Z")

</div>

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

> **···**
>
> On Aug 8, 2007, at 9:34 AM, vasudevram wrote:
> 
> > On Aug 8, 9:20 am, Mark Slater \<li...@humanesoftware.com\> wrote:
> > 
> > > 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](http://www.dancingbison.com)  
> > PDF creation/construction toolkit:  
> > &nbsp;&nbsp;[Conversion of other file formats to PDF download | SourceForge.net](http://sourceforge.net/projects/xtopdf)  
> > Blog: [http://jugad.livejournal.com](http://jugad.livejournal.com)

---

<div class="post-metadata">

**Author:** ![Jan\_Svitok](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Jan\_Svitok](https://rubytalk.org/u/Jan_Svitok)\
**Post date:** [9 August 2007 07:38 UTC](https://rubytalk.org/t/html-test-output/39747/5 "2007-08-09T07:38:18Z")

</div>

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

J.

> **···**
>
> On 8/8/07, Mark Slater \<lists@humanesoftware.com\> wrote:
> 
> > 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

---

<div class="post-metadata">

**Author:** ![Matt\_Berney](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Matt\_Berney](https://rubytalk.org/u/Matt_Berney)\
**Post date:** [9 August 2007 23:53 UTC](https://rubytalk.org/t/html-test-output/39747/6 "2007-08-09T23:53:18Z")

</div>

Mark Slater wrote:

> 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?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Mark\_Slater](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mark\_Slater](https://rubytalk.org/u/Mark_Slater)\
**Post date:** [9 August 2007 18:19 UTC](https://rubytalk.org/t/html-test-output/39747/7 "2007-08-09T18:19:14Z")

</div>

Well I've been searching, and unfortunately the best solution that used to exist (test-report) is gone, and I'm not comfortable tying our tests to software that doesn't exist anymore. Other solutions seem to be written for use with specific libraries (RSpec for example) and I don't want to introduce extra dependencies when all I need is a different logger.

So I've looked into writing my own; certainly the Console::TestRunner class isn't hard to understand and extend. The problem I've run into is that the rake TestTask only has the options attribute available to specify the test runner (t.options = "--runner=gtk", for example) and the list of available runners is baked into the Autorunners class. I haven't been able to add my custom runner to the list via the rake file because rake invokes a new process to run the tests (which is why the runner needs to be specified command-line-option-style).

At this point I'm looking at submitting a patch to Test::Unit with the new test runner that I make. I have to say though, with a language as dynamic as Ruby is, I'm surprised that the only \*clean\* way of adding a new test runner is to add it to the Test::Unit source; maybe I'm still too new though.

If I'm missing something, please let me know.

Mark

> **···**
>
> On Aug 9, 2007, at 12:38 AM, Jano Svitok wrote:
> 
> > On 8/8/07, Mark Slater \<lists@humanesoftware.com\> wrote:
> > 
> > > 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.

---

<div class="post-metadata">

**Author:** ![Matt\_Berney](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Matt\_Berney](https://rubytalk.org/u/Matt_Berney)\
**Post date:** [13 August 2007 16:07 UTC](https://rubytalk.org/t/html-test-output/39747/8 "2007-08-13T16:07:44Z")

</div>

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](http://www.w3.org/1999/XSL/Transform)"\>

\<xsl:template match="/"\>  
&nbsp;&nbsp;\<html\>  
&nbsp;&nbsp;\<body\>  
&nbsp;&nbsp;\<xsl:apply-templates/\>  
&nbsp;&nbsp;\</body\>  
&nbsp;&nbsp;\</html\>  
&nbsp;&nbsp;\</xsl:template\>

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

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

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

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Mark\_Slater](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Mark\_Slater](https://rubytalk.org/u/Mark_Slater)\
**Post date:** [15 August 2007 01:14 UTC](https://rubytalk.org/t/html-test-output/39747/9 "2007-08-15T01:14:07Z")

</div>

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

> **···**
>
> On Aug 13, 2007, at 9:07 AM, Matt Berney wrote:
> 
> > 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&quot;&gt](http://www.w3.org/1999/XSL/Transform&quot;&gt);
> > 
> > \<xsl:template match="/"\>  
> > &nbsp;&nbsp;\<html\>  
> > &nbsp;&nbsp;\<body\>  
> > &nbsp;&nbsp;\<xsl:apply-templates/\>  
> > &nbsp;&nbsp;\</body\>  
> > &nbsp;&nbsp;\</html\>  
> > &nbsp;&nbsp;\</xsl:template\>
> > 
> > \<xsl:template match="testsuite"\>  
> > &nbsp;&nbsp;\<h2\>Test Report:\<xsl:value-of select="@name"/\>\</h2\>  
> > &nbsp;&nbsp;\<table border="0"\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<b\>Number of Tests:\</b\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<xsl:value-of select="@tests"/\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<b\>Number of Failures:\</b\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<xsl:value-of select="@failures"/\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<b\>Execution Time:\</b\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<xsl:value-of select="@time"/\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<b\>Number of Tests:\</b\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<xsl:value-of select="@tests"/\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> > &nbsp;&nbsp;\</table\>  
> > &nbsp;&nbsp;\<h3\>Test Status\</h3\>  
> > &nbsp;&nbsp;\<table border="1"\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<tr bgcolor="#9acd32"\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<th align="left"\>Name\</th\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<th align="left"\>Status\</th\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<th align="left"\>Execution Time\</th\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\</tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<xsl:apply-templates select="testcase"/\>  
> > &nbsp;&nbsp;&nbsp;\</table\>  
> > \</xsl:template\>
> > 
> > \<xsl:template match="testcase"\>  
> > &nbsp;&nbsp;\<tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<xsl:value-of select="@name"/\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<xsl:variable name="bgcolor"\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<xsl:choose\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<xsl:when test="@status='Failed'"\>red\</xsl:when\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<xsl:otherwise\>\</xsl:otherwise\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</xsl:choose\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\</xsl:variable\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<td bgcolor="{$bgcolor}"\>\<xsl:value-of select="@status"/\>\</td\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<xsl:value-of select="@time"/\>\</td\>  
> > &nbsp;&nbsp;\</tr\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;\<xsl:apply-templates select="failure"/\>  
> > \</xsl:template\>
> > 
> > \<xsl:template match="failure"\>  
> > &nbsp;&nbsp;\<tr\>\<td colspan="3"\>\<xsl:value-of select="."/\>\</td\>\</tr\>  
> > \</xsl:template\>  
> > \</xsl:stylesheet\>  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
