我有一个在test :: unit框架中开发的简单项目,它工作正常。我想生成一个HTML测试报告,说明我使用传递/失败状态和其他相关数据执行的测试。
我有三个文件:
Rakefile(调用runner.rb文件):
task :default => :TestRunner
desc "run suite test"
task :TestRunner do
ruby "D:/TestUnit/runner.rb"
end
runner.rb(执行测试套件):
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
test_dir = File.join(base_dir, "testUnit/suite.rb")
require 'test/unit'
exit Test::Unit::AutoRunner.run(true, test_dir)
suite.rb(包含所有测试):
gem "test-unit"
require "test/unit"
class Test1< Test::Unit::TestCase
description "Test Case for adding two values..!!", :test_add
description "Test Case for subtracting two values..!!", :test_sub
def setup
puts "running the setup........."
@number1 = 4
@number2 = 2
end
def test_add
puts "asserting the add function: " + description
numb1=@number1+@number2
assert_equal(7, numb1 + 1, "added correctly")
end
def test_sub
puts "asserting the subtract function: " + description
numb2=@number1-@number2
assert_equal(2, numb2 - 0, "subtracted correctly")
end
def teardown
puts "running teardown......."
@number = nil
end
end
生成HTML测试报告还需要做什么?