module Betatest

Constants

VERSION

Public Class Methods

__run(reporter, options) click to toggle source

Internal run method. Responsible for telling all Runnable sub-classes to run.

NOTE: this method is redefined in parallel_each.rb, which is loaded if a Runnable calls parallelize_me!.

# File lib/betatest.rb, line 144
def self.__run reporter, options
  suites = Runnable.runnables.shuffle
  parallel, serial = suites.partition { |s| s.test_order == :parallel }

  # If we run the parallel tests before the serial tests, the parallel tests
  # could run in parallel with the serial tests. This would be bad because
  # the serial tests won't lock around Reporter#record. Run the serial tests
  # first, so that after they complete, the parallel tests will lock when
  # recording results.
  serial.map { |suite| suite.run reporter, options } +
    parallel.map { |suite| suite.run reporter, options }
end
after_run(&block) click to toggle source

A simple hook allowing you to run a block of code after everything is done running. Eg:

Betatest.after_run { p $debugging_info }
# File lib/betatest.rb, line 70
def self.after_run &block
  @@after_run << block
end
autorun() click to toggle source

Registers Betatest to run at process exit

# File lib/betatest.rb, line 42
def self.autorun
  at_exit {
    next if $! and not ($!.kind_of? SystemExit and $!.success?)

    # Keep track of the testing process pid, so that we don't accidentally run the @@after_run handlers in children processes (e.g. Process.fork).
    @@testing_process_pid = Process.pid

    exit_code = nil

    at_exit {
      # Don't do anything if we aren't the testing process.
      next if Process.pid != @@testing_process_pid

      @@after_run.reverse_each(&:call)
      exit exit_code || false
    }

    exit_code = Betatest.run ARGV
  } unless @@installed_at_exit
  @@installed_at_exit = true
end
run(args = []) click to toggle source

This is the top-level run method. Everything starts from here. It tells each Runnable sub-class to run, and each of those are responsible for doing whatever they do.

The overall structure of a run looks like this:

Betatest.autorun
  Betatest.run(args)
    Betatest.__run(reporter, options)
      Runnable.runnables.each
        runnable.run(reporter, options)
          self.runnable_methods.each
            self.run_one_method(self, runnable_method, reporter)
              Betatest.run_one_method(klass, runnable_method, reporter)
                klass.new(runnable_method).run
# File lib/betatest.rb, line 116
def self.run args = []
  self.load_plugins

  options = process_args args

  reporter = CompositeReporter.new
  reporter << SummaryReporter.new(options[:io], options)
  reporter << ProgressReporter.new(options[:io], options)

  self.reporter = reporter # this makes it available to plugins
  self.init_plugins options
  self.reporter = nil # runnables shouldn't depend on the reporter, ever

  reporter.start
  __run reporter, options
  self.parallel_executor.shutdown
  reporter.report

  reporter.passed?
end

Public Instance Methods

unknown() click to toggle source

Parallel test executor

# File lib/betatest.rb, line 19
mc.send :attr_accessor, :parallel_executor