test-parser

Get Version

0.11.0

Overview

A collection of parsers for a variety of automated test systems. Currently including support for rspec, rubyunit, pyunit, and even preliminary support for Haskell’s quickCheck.

Parsing returns a data structure that describes the results of the testing, including detailed failure information. Furthermore, this output is consistent across all of the parsers, allowing abstraction across different testing systems.

Installing

sudo gem install test-parser

or perhaps

gem install test-parser

And yes, when you’re asked, you do want those dependencies.

Of course, ruby and gem must be installed first.

Demonstration of usage

Included is a script that will parse the output of a set of tests and print out a YAML representation of the results.

Since we need a test suite to show this example on, we might as well test test-parser itself. 1


~>> svn checkout svn://rubyforge.org/var/svn/test-parser/
[...]
A    test-parser/README.txt
A    test-parser/examples
Checked out revision 14.
~>> cd test-parser
~/test-parser>> test_parser 
usage: test_parser <test_framework>
  Frameworks:
     rspec
     rubyunit
     pyunit
     quickCheck
~/test_parser>> spec spec/test_parsers_spec.rb | test_parser rspec
- 
:success_count: 28
:failures: []

:failure_count: 0
:test_count: 28

And thus you can see that test-parser has 28 tests, and all of them pass successfully.2 More importantly, you could use YAML to get easy access to this information with another program in your toolchain.

You could do something equivalent in Ruby with something like the following:

 
require "test-parser"
test_file = "spec/test_parsers_spec.rb"
parsed_test = TestParser::RSpec.parse(open("|spec #{test_file}").read)
parsed_test.inspect #==> {:test_count=>22, :success_count=>22, :failures=>[], :failure_count=>0}

More Information

The output of the various parsers is consistent across a number of varied test systems. These test systems have different goals, methods, and levels of detail in their output.

That said, the output of the different parsers is very consistent and usable. There’s a list of guarantees on this data here.

Forum

http://groups.google.com/group/test-parser

Suggestions and bug reports welcome. Or you can come and suggest the next test system to add :)

How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

The trunk repository is svn://rubyforge.org/var/svn/test-parser/ for anonymous access.

License

This code is free to use under the terms of the MIT license. It is also released under the Ruby License.

Contact

Comments are welcome. Send an email to Peter Burns.

1) requires rspec, easily installed via sudo gem install rspec

2) This, you may notice, is more than the 22 tests in 0.8.0. This reflects the additional tests for the preliminary junit support that’s coming in 0.9.0. Shhh!

Dr Nic
Theme extended from Paul Battley