Patch #226 » auto_test_suite.rb
1 |
|
---|---|
2 |
# Move the path to the location of the current file
|
3 |
Dir.chdir(File.dirname(File.expand_path(__FILE__))) |
4 |
|
5 |
Thread.abort_on_exception = true |
6 |
|
7 |
# Require the unit test libs
|
8 |
require 'test/unit/testsuite' |
9 |
require 'test/unit/ui/console/testrunner' |
10 |
require 'test/unit/testcase' |
11 |
|
12 |
def find_test_suites(dir_name, classes_to_exclude=[]) |
13 |
(Dir.entries(dir_name) - ['.', '..']).each do |file| |
14 |
next unless file.downcase[-8..-1] == "_test.rb" |
15 |
require "#{dir_name}/#{file}" |
16 |
end
|
17 |
|
18 |
suites = [] |
19 |
ObjectSpace.each_object(Class) do |klass| |
20 |
next unless klass.superclass == Test::Unit::TestCase or klass.superclass == ActionController::IntegrationTest |
21 |
next if klass.name.include? "ActionController::" |
22 |
next if classes_to_exclude.include? klass.suite |
23 |
suites << klass.suite |
24 |
end
|
25 |
suites
|
26 |
end
|
27 |
|
28 |
class TestSuite |
29 |
def self.suite |
30 |
master_suite = Test::Unit::TestSuite.new |
31 |
|
32 |
unit_tests = find_test_suites('unit') |
33 |
functional_tests = find_test_suites('functional', unit_tests) |
34 |
integration_tests = find_test_suites('integration', unit_tests + functional_tests) |
35 |
|
36 |
[unit_tests, |
37 |
functional_tests, |
38 |
integration_tests].each do |suite_set| |
39 |
suite_set.each do |suite| |
40 |
master_suite << suite |
41 |
end
|
42 |
end
|
43 |
|
44 |
return master_suite |
45 |
end
|
46 |
end
|
47 |
|
48 |
Test::Unit::UI::Console::TestRunner.run(TestSuite) |
49 |
|
50 |
|
- « Previous
- 1
- 2
- Next »