Created
June 5, 2009 13:53
-
-
Save chrismcg/124290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'midiator' | |
require 'test/unit/ui/console/testrunner' | |
module Test | |
module Unit | |
module UI | |
module Midi | |
# Runs a Test::Unit::TestSuite on the console. | |
class TestRunner < ::Test::Unit::UI::Console::TestRunner | |
include MIDIator::Notes | |
def initialize(suite, output_level=NORMAL, io=STDOUT) | |
super | |
@midi = MIDIator::Interface.new | |
@midi.use :dls_synth | |
@midi.instruct_user! | |
end | |
private | |
def add_fault(fault) | |
@midi.play Cs4 | |
super | |
end | |
def test_finished(name) | |
unless (@already_outputted) | |
@midi.play C4 | |
end | |
super | |
end | |
end | |
end | |
end | |
end | |
end | |
if __FILE__ == $0 | |
class MidiTestRunnerTestCase < Test::Unit::TestCase | |
100.times do |i| | |
define_method "test_#{i}" do | |
assert rand > 0.5 | |
end | |
end | |
end | |
Test::Unit::UI::Midi::TestRunner.new(MidiTestRunnerTestCase).start | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment