Class: Bozo::TestRunners::DotCover

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

Overview

Adds a code coverage test runner using dotCover

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

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDotCover

Returns a new instance of DotCover.



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

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

  @config = {}
  @runners = []
end

Class Method Details

.default_pathObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bozo/test_runners/dotcover.rb', line 12

def self.default_path
  if ENV['teamcity.dotCover.home'].nil?
    if ENV['ProgramFiles(x86)'].nil?
      program_files_path = ENV['ProgramFiles']
    else
      program_files_path = ENV['ProgramFiles(x86)']
    end

    File.join(program_files_path, 'JetBrains', 'dotCover', 'v1.2', 'Bin', 'dotcover.exe')
  else
    File.join(ENV['teamcity.dotCover.home'], 'dotcover.exe')
  end
end

Instance Method Details

#dotcover_installed?Boolean

Returns whether dotcover is installed at the configured path

Returns:

  • (Boolean)


37
38
39
40
41
42
43
# File 'lib/bozo/test_runners/dotcover.rb', line 37

def dotcover_installed?
  path = configuration[:path]

  return false if path.nil?

  File.exist? path
end

#executeObject



67
68
69
70
71
72
73
# File 'lib/bozo/test_runners/dotcover.rb', line 67

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

#required?(required = nil) ⇒ Boolean

Specifies whether covering with dotcover is required

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

Parameters:

  • required (boolean) (defaults to: nil)

    Whether dotCover coverage is required

Returns:

  • (Boolean)


61
62
63
64
65
# File 'lib/bozo/test_runners/dotcover.rb', line 61

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

#runner(runner, &block) ⇒ Object

Adds a test runner

Parameters:

  • runner (Symbol)

    A test runner to wrap with dotcover



49
50
51
# File 'lib/bozo/test_runners/dotcover.rb', line 49

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