Sha256: e714f968a9da08830982f76267c219028b49be8c19587a048ce042d3e666c69f

Contents?: true

Size: 1.77 KB

Versions: 18

Compression:

Stored size: 1.77 KB

Contents

require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rake/testtask'

desc "Run all tests"
task 'default' => ['test:units', 'test:acceptance', 'test:performance']

namespace 'test' do
  unit_tests       = FileList['test/unit/**/*_test.rb']
  acceptance_tests = FileList['test/acceptance/*_test.rb']

  desc "Run unit tests"
  Rake::TestTask.new('units') do |t|
    t.libs << 'test'
    t.test_files = unit_tests
  end

  desc "Run acceptance tests"
  Rake::TestTask.new('acceptance') do |t|
    t.libs << 'test'
    t.test_files = acceptance_tests
  end

  desc "Run performance tests"
  task 'performance' do
    require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'stubba_example_test')
    require File.join(File.dirname(__FILE__), 'test', 'acceptance', 'mocha_example_test')
    iterations = 1000
    puts "\nBenchmarking with #{iterations} iterations..."
    [MochaExampleTest, StubbaExampleTest].each do |test_case|
      puts "#{test_case}: #{benchmark_test_case(test_case, iterations)} seconds."
    end
  end
end

def benchmark_test_case(klass, iterations)
  require 'benchmark'

  if defined?(MiniTest)
    MiniTest::Unit.output = StringIO.new
    Benchmark.realtime { iterations.times { |i| MiniTest::Unit.new.run([klass]) } }
  else
    load 'test/unit/ui/console/testrunner.rb' unless defined?(Test::Unit::UI::Console::TestRunner)
    unless $silent_option
      begin
        load 'test/unit/ui/console/outputlevel.rb' unless defined?(Test::Unit::UI::Console::OutputLevel::SILENT)
        $silent_option = { :output_level => Test::Unit::UI::Console::OutputLevel::SILENT }
      rescue LoadError
        $silent_option = Test::Unit::UI::SILENT
      end
    end
    Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, $silent_option) } }
  end
end

Version data entries

18 entries across 17 versions & 3 rubygems

Version Path
bourne-1.6.0 Rakefile
bourne-1.5.0 Rakefile
challah-1.0.0.beta3 vendor/bundle/gems/bourne-1.4.0/Rakefile
challah-1.0.0.beta2 vendor/bundle/gems/bourne-1.4.0/Rakefile
challah-1.0.0.beta vendor/bundle/gems/bourne-1.4.0/Rakefile
challah-1.0.0.beta vendor/bundle/gems/bourne-1.1.2/Rakefile
bourne-1.4.0 Rakefile
bourne-1.3.2 Rakefile
challah-0.9.1.beta.3 vendor/bundle/gems/bourne-1.1.2/Rakefile
devise_sociable-0.1.0 vendor/bundle/gems/bourne-1.1.2/Rakefile
challah-0.9.1.beta vendor/bundle/gems/bourne-1.1.2/Rakefile
challah-0.9.0 vendor/bundle/gems/bourne-1.1.2/Rakefile
bourne-1.3.0 Rakefile
bourne-1.2.1 Rakefile
bourne-1.2.0 Rakefile
bourne-1.1.2 Rakefile
bourne-1.1.1 Rakefile
bourne-1.1.0 Rakefile