Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 55 lines (47 sloc) 1.815 kB
9d21677 @gabebw bundler/setup is important.
gabebw authored
1 require 'bundler/setup'
b3e9745 @gabebw Use Bundler gem conventions.
gabebw authored
2 require 'bundler/gem_tasks'
f61e789 @jferris Moved changes from jferris-mocha into a separate repo that monkey-pat…
jferris authored
3 require 'rake/testtask'
4
5 desc "Run all tests"
6 task 'default' => ['test:units', 'test:acceptance', 'test:performance']
7
8 namespace 'test' do
b3e9745 @gabebw Use Bundler gem conventions.
gabebw authored
9 unit_tests = FileList['test/unit/**/*_test.rb']
f61e789 @jferris Moved changes from jferris-mocha into a separate repo that monkey-pat…
jferris authored
10 acceptance_tests = FileList['test/acceptance/*_test.rb']
11
12 desc "Run unit tests"
13 Rake::TestTask.new('units') do |t|
14 t.libs << 'test'
15 t.test_files = unit_tests
16 end
17
18 desc "Run acceptance tests"
19 Rake::TestTask.new('acceptance') do |t|
20 t.libs << 'test'
21 t.test_files = acceptance_tests
22 end
23
24 desc "Run performance tests"
25 task 'performance' do
26 require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'stubba_example_test')
27 require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'mocha_example_test')
28 iterations = 1000
f31aa72 @gabebw Revert silly change.
gabebw authored
29 puts "\nBenchmarking with #{iterations} iterations..."
f61e789 @jferris Moved changes from jferris-mocha into a separate repo that monkey-pat…
jferris authored
30 [MochaExampleTest, StubbaExampleTest].each do |test_case|
31 puts "#{test_case}: #{benchmark_test_case(test_case, iterations)} seconds."
32 end
33 end
34 end
35
36 def benchmark_test_case(klass, iterations)
37 require 'benchmark'
50e94e9 @sikachu Now working with Ruby 1.9.x (with Minitest 2.5.x)
sikachu authored
38
39 if defined?(MiniTest)
40 MiniTest::Unit.output = StringIO.new
41 Benchmark.realtime { iterations.times { |i| MiniTest::Unit.new.run([klass]) } }
42 else
43 load 'test/unit/ui/console/testrunner.rb' unless defined?(Test::Unit::UI::Console::TestRunner)
44 unless $silent_option
45 begin
46 load 'test/unit/ui/console/outputlevel.rb' unless defined?(Test::Unit::UI::Console::OutputLevel::SILENT)
47 $silent_option = { :output_level => Test::Unit::UI::Console::OutputLevel::SILENT }
48 rescue LoadError
49 $silent_option = Test::Unit::UI::SILENT
50 end
51 end
52 Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, $silent_option) } }
f61e789 @jferris Moved changes from jferris-mocha into a separate repo that monkey-pat…
jferris authored
53 end
54 end
Something went wrong with that request. Please try again.