Class: Minitest::Ci

Inherits:
Reporter
  • Object
show all
Defined in:
lib/minitest/ci_plugin.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, options = {}
  self.io      = io
  self.options = options
  self.results = Hash.new {|h,k| h[k] = []}
end

Class Attribute Details

.cleanObject

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_dirObject

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_dirObject

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

#ioObject

Returns the value of attribute io


66
67
68
# File 'lib/minitest/ci_plugin.rb', line 66

def io
  @io
end

#optionsObject

Returns the value of attribute options


67
68
69
# File 'lib/minitest/ci_plugin.rb', line 67

def options
  @options
end

#resultsObject

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?

Returns:

  • (Boolean)

45
46
47
# File 'lib/minitest/ci_plugin.rb', line 45

def report?
  @report ||= false
end

Instance Method Details

#passed?Boolean

Returns:

  • (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

#reportObject

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

#startObject

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