== ReportTestUnit
Version 1.0.0 - 2007-09-14
ReportTestUnit is an add on to the Test::Unit package. It leverages the full support
of Test:Unit to write out html based reports of each test case. ReportTestUnit is
designed to work with cruisecontrol.rb - but not limited to it.
=== Installation
Installed as a gem:
gem install reportTestUnit-x.y.z.gem (where x.y.z is the revision number)
or directly from rubyforge.net
gem install reportTestUnit
=== Dependencies
ReportTestUnit is built on top of Test::Unit which is part of the core package of ruby 1.8
=== Usage
ReportTestUnit subclasses the Test::Unit package, as such it is used similarly to
Test::Unit (Please see the Test::Unit rdoc for information on how to use Test::Unit).
A test suite might look like the following:
ts_test.rb
require 'reportUnitTest'
require 'test_cases/tc_test1.rb'
class TS_MyTests
def self.suite
suite = Test::Unit::TestSuite.new
suite << TestTc_test.suite
return suite
end
end
Report::TestUnit::UI::Report::TestRunner.run(TS_MyTests, 3) # 3 is verbose
And a test case might look like:
test_cases/tc_test1.rb
require 'test/unit'
test class is written exactly the same as for Test::Unit only its subclasses Report::TestUnit::TestCase
instead of Test::Unit::TestCase (Report::TestUnit::TestCase is a subclass of Test::Unit:TestCase
class TestTc_test < Report::TestUnit::TestCase
def setup
# override default settings if needed
end
def teardown
# override default settings if needed
end
def test_get_user_id
assert_equal(100, 99+1) # (test cases written exactly the same as for Test::Unit
end
end
The html report will be dropped in a directory specified by the ENV var UNIT_TEST_REPORT_DIR under this directory an index.html file will be created along with a classes directory populated with html files for each test_case class.
To integrate with CruiseControl.rb add the following line to your rakefile:
ENV['UNIT_TEST_REPORT_DIR']="#{ENV['CC_BUILD_ARTIFACTS']}/unitTestReport"
=== Acknowledgements
As this package is built on Test::Unit all the credit must go to those guys for
providing excellent opportunities to plug in extra functionality.
=== License
Copyright (c) 2007, TSSG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the "Waterford Institute of Technology" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.