Class: MicroTest::Runner
- Inherits:
-
Object
- Object
- MicroTest::Runner
- Defined in:
- lib/micro_test/runner.rb
Class Attribute Summary collapse
-
.exit ⇒ Object
Returns the value of attribute exit.
Instance Attribute Summary collapse
-
#active_test ⇒ Object
readonly
Returns the value of attribute active_test.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#failed ⇒ Object
readonly
Returns the value of attribute failed.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#passed ⇒ Object
readonly
Returns the value of attribute passed.
Instance Method Summary collapse
-
#initialize(formatter, options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #reset ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(formatter, options = {}) ⇒ Runner
Returns a new instance of Runner.
12 13 14 15 16 |
# File 'lib/micro_test/runner.rb', line 12 def initialize(formatter, ={}) @formatter = formatter @options = reset end |
Class Attribute Details
.exit ⇒ Object
Returns the value of attribute exit.
7 8 9 |
# File 'lib/micro_test/runner.rb', line 7 def exit @exit end |
Instance Attribute Details
#active_test ⇒ Object (readonly)
Returns the value of attribute active_test.
10 11 12 |
# File 'lib/micro_test/runner.rb', line 10 def active_test @active_test end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
10 11 12 |
# File 'lib/micro_test/runner.rb', line 10 def duration @duration end |
#failed ⇒ Object (readonly)
Returns the value of attribute failed.
10 11 12 |
# File 'lib/micro_test/runner.rb', line 10 def failed @failed end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
10 11 12 |
# File 'lib/micro_test/runner.rb', line 10 def formatter @formatter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/micro_test/runner.rb', line 10 def @options end |
#passed ⇒ Object (readonly)
Returns the value of attribute passed.
10 11 12 |
# File 'lib/micro_test/runner.rb', line 10 def passed @passed end |
Instance Method Details
#reset ⇒ Object
48 49 50 51 52 |
# File 'lib/micro_test/runner.rb', line 48 def reset @duration = 0 @passed = 0 @failed = 0 end |
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/micro_test/runner.rb', line 18 def run test_classes = MicroTest::Test.subclasses.shuffle tests = test_classes.map{ |klass| klass.tests }.flatten formatter.before_suite(test_classes) start = Time.now test_classes.each do |test_class| formatter.before_class(test_class) test_class.tests.shuffle.each do |test| @active_test = test if @options[:async] @tests ||= Queue.new @tests << test else test.invoke(@formatter, @options) end end formatter.after_class(test_class) end run_threads if @options[:async] @duration = Time.now - start @passed = tests.select{ |test| test.passed? }.count @failed = tests.select{ |test| !test.passed? }.count formatter.after_results(self) formatter.after_suite(test_classes) @failed end |