Class: Bozo::TestRunners::OpenCover

Inherits:
Object
  • Object
show all
Defined in:
lib/bozo/test_runners/opencover.rb

Overview

Adds a code coverage test runner using openCover

The default configuration looks for openCover in the ProgramFiles(x86) path

Test runners can be defined foropenCover to run against. Each runner produces a separate dotcover output

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOpenCover

Returns a new instance of OpenCover.



16
17
18
19
20
21
22
23
24
# File 'lib/bozo/test_runners/opencover.rb', line 16

def initialize
  @@defaults = {
    :path => OpenCover.default_path,
    :required => true
  }

  @config = {}
  @runners = []
end

Class Method Details

.default_pathObject



12
13
14
# File 'lib/bozo/test_runners/opencover.rb', line 12

def self.default_path
  File.join('build', 'tools', 'OpenCover', 'OpenCover.Console.exe')
end

Instance Method Details

#executeObject



63
64
65
66
67
68
69
# File 'lib/bozo/test_runners/opencover.rb', line 63

def execute
  if required? or opencover_installed?
    @runners.each {|runner| execute_with_coverage runner}
  else
    @runners.each {|runner| execute_without_coverage(runner)}
  end
end

#opencover_installed?Boolean

Returns whether opencover is installed at the configured path

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/bozo/test_runners/opencover.rb', line 27

def opencover_installed?
  path = configuration[:path]

  return false if path.nil?

  File.exist? path
end

#required?(required = nil) ⇒ Boolean

Specifies whether covering with opencover is required

If it is not required, and opencover cannot be found, then test runners are executed without coverage. If opencover is required but cannot be found then an error will occur.

Parameters:

  • required (boolean) (defaults to: nil)

    Whether opencover coverage is required

Returns:

  • (Boolean)


57
58
59
60
61
# File 'lib/bozo/test_runners/opencover.rb', line 57

def required?(required = nil)
  @config[:required] = required unless required.nil?
  
  @config[:required]
end

#required_toolsObject

Returns the build tools required for this dependency resolver to run successfully.



37
38
39
# File 'lib/bozo/test_runners/opencover.rb', line 37

def required_tools
  :open_cover
end

#runner(runner, &block) ⇒ Object

Adds a test runner

Parameters:

  • runner (Symbol)

    A test runner to wrap with opencover



45
46
47
# File 'lib/bozo/test_runners/opencover.rb', line 45

def runner(runner, &block)
  add_instance runner, block
end