# HTML test output?

**URL:** <https://www.ruby-forum.com/t/html-test-output/111515>\
**Category:** Ruby\
**Created:** [August 8, 2007, 6:21am UTC](https://www.ruby-forum.com/t/html-test-output/111515 "2007-08-08T06:21:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 8, 2007, 6:21am UTC](https://www.ruby-forum.com/t/html-test-output/111515/1 "2007-08-08T06:21:45Z")

</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:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 8, 2007, 6:38pm UTC](https://www.ruby-forum.com/t/html-test-output/111515/2 "2007-08-08T18:38:11Z")

</div>

On Aug 8, 9:20 am, Mark S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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:  
[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:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 8, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/html-test-output/111515/3 "2007-08-08T22:53:22Z")

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

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 9, 2007, 9:39am UTC](https://www.ruby-forum.com/t/html-test-output/111515/4 "2007-08-09T09:39:21Z")

</div>

On 8/8/07, Mark S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 9, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/html-test-output/111515/5 "2007-08-09T20:19:43Z")

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

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 9, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/html-test-output/111515/6 "2007-08-09T20:27:44Z")

</div>

On 8/7/07, Mark S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Check out the ci-reporter rails plugin and gem.

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 10, 2007, 1:53am UTC](https://www.ruby-forum.com/t/html-test-output/111515/7 "2007-08-10T01:53:20Z")

</div>

Mark S. 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?

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 13, 2007, 6:07pm UTC](https://www.ruby-forum.com/t/html-test-output/111515/8 "2007-08-13T18:07:46Z")

</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=“[XSLT Namespace](http://www.w3.org/1999/XSL/Transform)”\>

\<xsl:template match=“/”\>

\<xsl:template match=“testsuite”\>

## Test Report:

| **Number of Tests:** | |
| **Number of Failures:** | |
| **Execution Time:** | |
| **Number of Tests:** | |

### Test Status

| Name | Status | Execution Time |
| --- | --- | --- |

\<xsl:template match=“testcase”\>

 red 

\<xsl:template match=“failure”\>

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [August 15, 2007, 3:15am UTC](https://www.ruby-forum.com/t/html-test-output/111515/9 "2007-08-15T03:15:26Z")

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