Class: Minitest::Ci
- Inherits:
-
Reporter
- Object
- Reporter
- Minitest::Ci
- Defined in:
- lib/minitest/ci_plugin.rb
Class Attribute Summary collapse
-
.clean ⇒ Object
Clean the report_dir between test runs? (defaults to true).
-
.report_dir ⇒ Object
Change the report directory.
-
.working_dir ⇒ Object
Change the working directory.
Instance Attribute Summary collapse
-
#io ⇒ Object
Returns the value of attribute io.
-
#options ⇒ Object
Returns the value of attribute options.
-
#results ⇒ Object
Returns the value of attribute results.
Class Method Summary collapse
-
.report! ⇒ Object
Activates minitest/ci plugin as a Minitest reporter.
-
.report? ⇒ Boolean
Is minitest/ci activated as a Minitest reporter?.
Instance Method Summary collapse
-
#initialize(io = $stdout, options = {}) ⇒ Ci
constructor
A new instance of Ci.
- #passed? ⇒ Boolean
- #record(result) ⇒ Object
-
#report ⇒ Object
Generate test report.
-
#start ⇒ Object
clean.
Constructor Details
#initialize(io = $stdout, options = {}) ⇒ Ci
Returns a new instance of Ci.
70 71 72 73 74 |
# File 'lib/minitest/ci_plugin.rb', line 70 def initialize io = $stdout, = {} self.io = io self. = self.results = Hash.new {|h,k| h[k] = []} end |
Class Attribute Details
.clean ⇒ Object
Clean the report_dir between test runs? (defaults to true)
55 56 57 |
# File 'lib/minitest/ci_plugin.rb', line 55 def clean @clean end |
.report_dir ⇒ Object
Change the report directory. (defaults to “test/reports”)
51 52 53 |
# File 'lib/minitest/ci_plugin.rb', line 51 def report_dir @report_dir end |
.working_dir ⇒ Object
Change the working directory. (defaults to ‘$PWD`)
59 60 61 |
# File 'lib/minitest/ci_plugin.rb', line 59 def working_dir @working_dir end |
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
66 67 68 |
# File 'lib/minitest/ci_plugin.rb', line 66 def io @io end |
#options ⇒ Object
Returns the value of attribute options.
67 68 69 |
# File 'lib/minitest/ci_plugin.rb', line 67 def @options end |
#results ⇒ Object
Returns the value of attribute results.
68 69 70 |
# File 'lib/minitest/ci_plugin.rb', line 68 def results @results end |
Class Method Details
.report! ⇒ Object
Activates minitest/ci plugin as a Minitest reporter
39 40 41 |
# File 'lib/minitest/ci_plugin.rb', line 39 def report! @report = true end |
.report? ⇒ Boolean
Is minitest/ci activated as a Minitest reporter?
45 46 47 |
# File 'lib/minitest/ci_plugin.rb', line 45 def report? @report ||= false end |
Instance Method Details
#passed? ⇒ Boolean
76 77 78 |
# File 'lib/minitest/ci_plugin.rb', line 76 def passed? true # don't care? end |
#record(result) ⇒ Object
85 86 87 88 |
# File 'lib/minitest/ci_plugin.rb', line 85 def record result key = result.respond_to?(:klass) ? result.klass : result.class results[key] << result end |
#report ⇒ Object
Generate test report
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/minitest/ci_plugin.rb', line 92 def report io.puts io.puts '[Minitest::CI] Generating test report in JUnit XML format...' Dir.chdir report_dir do results.each do |name, result| File.open(report_name(name), "w") do |f| f.puts( generate_results(name, result) ) end end end end |
#start ⇒ Object
clean
80 81 82 83 |
# File 'lib/minitest/ci_plugin.rb', line 80 def start # clean FileUtils.rm_rf report_dir if clean? FileUtils.mkdir_p report_dir end |