Class: Spout::HiddenReporter
- Inherits:
-
Turn::Reporter
- Object
- Turn::Reporter
- Spout::HiddenReporter
- Defined in:
- lib/spout/hidden_reporter.rb
Overview
Based on Pretty Reporter (by Paydro)
Modified to hide passing tests
Example output:
TestCaseName:
PASS test: Succesful test case. (0:00:02:059)
ERROR test: Bogus test case. (0:00:02:059)
FAIL test: Failed test case. (0:00:02:059)
Constant Summary collapse
- TAB_SIZE =
Second column left padding in chars.
10
- TRACE_MARK =
Character to put in front of backtrace.
'@ '
Instance Method Summary collapse
-
#error(exception, message = nil) ⇒ Object
Invoked when a test raises an exception.
-
#fail(assertion, message = nil) ⇒ Object
Invoked when a test raises an assertion.
-
#finish_case(kase) ⇒ Object
Invoked after all tests in a testcase have ben run.
-
#finish_suite(suite) ⇒ Object
After all tests are run, this is the last observable action.
-
#initialize(hide_passing_tests) ⇒ HiddenReporter
constructor
A new instance of HiddenReporter.
-
#pass(message = nil) ⇒ Object
Invoked when a test passes.
-
#skip(exception, message = nil) ⇒ Object
Invoked when a test is skipped.
-
#start_case(kase) ⇒ Object
Invoked before a testcase is run.
-
#start_suite(suite) ⇒ Object
At the very start, before any testcases are run, this is called.
-
#start_test(test) ⇒ Object
Invoked before a test is run.
Constructor Details
#initialize(hide_passing_tests) ⇒ HiddenReporter
Returns a new instance of HiddenReporter.
20 21 22 23 24 25 26 27 |
# File 'lib/spout/hidden_reporter.rb', line 20 def initialize(hide_passing_tests) @io = $stdout @trace = nil @natural = nil @verbose = nil @mark = 0 @hide_passing_tests = hide_passing_tests end |
Instance Method Details
#error(exception, message = nil) ⇒ Object
Invoked when a test raises an exception.
79 80 81 82 83 |
# File 'lib/spout/hidden_reporter.rb', line 79 def error(exception, =nil) ERROR prettify(exception, ) end |
#fail(assertion, message = nil) ⇒ Object
Invoked when a test raises an assertion.
72 73 74 75 76 |
# File 'lib/spout/hidden_reporter.rb', line 72 def fail(assertion, =nil) FAIL prettify(assertion, ) end |
#finish_case(kase) ⇒ Object
Invoked after all tests in a testcase have ben run.
93 94 95 96 |
# File 'lib/spout/hidden_reporter.rb', line 93 def finish_case(kase) # Print newline is there any tests in suite io.puts if kase.size > 0 end |
#finish_suite(suite) ⇒ Object
After all tests are run, this is the last observable action.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/spout/hidden_reporter.rb', line 99 def finish_suite(suite) total = colorize_count("%d tests", suite.count_tests, :bold) passes = colorize_count("%d passed", suite.count_passes, :pass) assertions = colorize_count("%d assertions", suite.count_assertions, nil) failures = colorize_count("%d failures", suite.count_failures, :fail) errors = colorize_count("%d errors", suite.count_errors, :error) skips = colorize_count("%d skips", suite.count_skips, :skip) io.puts "Finished in %.6f seconds." % (Time.now - @time) io.puts io.puts [ total, passes, failures, errors, skips, assertions ].join(", ") # Please keep this newline, since it will be useful when after test case # there will be other lines. For example "rake aborted!" or kind of. io.puts end |
#pass(message = nil) ⇒ Object
Invoked when a test passes.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/spout/hidden_reporter.rb', line 58 def pass(=nil) unless @hide_passing_tests PASS if = Turn::Colorize.magenta() = .to_s.tabto(TAB_SIZE) io.puts() end end end |
#skip(exception, message = nil) ⇒ Object
Invoked when a test is skipped.
86 87 88 89 90 |
# File 'lib/spout/hidden_reporter.rb', line 86 def skip(exception, =nil) SKIP prettify(exception, ) end |
#start_case(kase) ⇒ Object
Invoked before a testcase is run.
45 46 47 48 49 |
# File 'lib/spout/hidden_reporter.rb', line 45 def start_case(kase) # Print case name if there any tests in suite # TODO: Add option which will show all test cases, even without tests? io.puts kase.name if kase.size > 0 end |
#start_suite(suite) ⇒ Object
At the very start, before any testcases are run, this is called.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/spout/hidden_reporter.rb', line 30 def start_suite(suite) @suite = suite @time = Time.now io.puts Turn::Colorize.bold("Loaded Suite #{suite.name}") io.puts if suite.seed io.puts "Started at #{Time.now} w/ seed #{suite.seed}." else io.puts "Started at #{Time.now}." end io.puts end |
#start_test(test) ⇒ Object
Invoked before a test is run.
52 53 54 55 |
# File 'lib/spout/hidden_reporter.rb', line 52 def start_test(test) @test_time = Time.now @test = test end |