README.txt in minitest-5.0.3 vs README.txt in minitest-5.0.4
- old
+ new
@@ -243,19 +243,59 @@
module Minitest
def self.plugin_bogus_options(opts, options)
opts.on "--myci", "Report results to my CI" do
options[:myci] = true
+ options[:myci_addr] = get_myci_addr
+ options[:myci_port] = get_myci_port
end
end
def self.plugin_bogus_init(options)
- ARGV << "-p" # all pride, all the time
- self.reporter << MyCI.new if options[:myci]
+ self.reporter << MyCI.new(options) if options[:myci]
end
end
+=== Adding custom reporters
+
+Minitest uses composite reporter to output test results using multiple
+reporter instances. You can add new reporters to the composite during
+the init_plugins phase. As we saw in +plugin_bonus_init+ above, you
+simply add your reporter instance to the composite via +<<+.
+
++AbstractReporter+ defines the API for reporters. You may subclass it
+and override any method you want to achieve your desired behavior.
+
+start :: Called when the run has started.
+record :: Called for each result, passed or otherwise.
+report :: Called at the end of the run.
+passed? :: Called to see if you detected any problems.
+
+Using our example above, here is how we might implement MyCI:
+
+ # minitest/bogus_plugin.rb
+
+ module Minitest
+ class MyCI < AbstractReporter
+ attr_accessor :results, :addr, :port
+
+ def initialize options
+ self.results = []
+ self.addr = options[:myci_addr]
+ self.port = options[:myci_port]
+ end
+
+ def record result
+ self.results << result
+ end
+
+ def report
+ CI.connect(addr, port).send_results self.results
+ end
+ end
+ end
+
== FAQ
=== How to test SimpleDelegates?
The following implementation and test:
@@ -354,9 +394,10 @@
minitest-instrument :: Instrument ActiveSupport::Notifications when
test method is executed
minitest-instrument-db :: Store information about speed of test
execution provided by minitest-instrument in database
minitest-libnotify :: Test notifier for minitest via libnotify.
+minitest-line :: Run test at line number
minitest-macruby :: Provides extensions to minitest for macruby UI testing.
minitest-matchers :: Adds support for RSpec-style matchers to minitest.
minitest-metadata :: Annotate tests with metadata (key-value).
minitest-mongoid :: Mongoid assertion matchers for MiniTest
minitest-must_not :: Provides must_not as an alias for wont in MiniTest