Class: Smartest::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/smartest/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(suite: Smartest.suite, reporter: Reporter.new) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
# File 'lib/smartest/runner.rb', line 5

def initialize(suite: Smartest.suite, reporter: Reporter.new)
  @suite = suite
  @reporter = reporter
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/smartest/runner.rb', line 10

def run
  results = []
  suite_cleanup_errors = []
  @suite_fixture_set = nil

  @reporter.start(@suite.tests.count)

  begin
    @suite.tests.each do |test_case|
      result = run_one(test_case)
      results << result
      @reporter.record(result)
    end
  ensure
    suite_cleanup_errors = @suite_fixture_set.run_cleanups if @suite_fixture_set
    @suite_fixture_set = nil
  end

  @reporter.finish(results, suite_cleanup_errors: suite_cleanup_errors)

  results.any?(&:failed?) || suite_cleanup_errors.any? ? 1 : 0
end