Class: Bozo::TestRunners::Mspec

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

Overview

A TestRunner for MSpec

Instance Method Summary collapse

Constructor Details

#initializeMspec

Returns a new instance of Mspec.



6
7
8
# File 'lib/bozo/test_runners/mspec.rb', line 6

def initialize
  @projects = []
end

Instance Method Details

#agents(agents) ⇒ Object



22
23
24
# File 'lib/bozo/test_runners/mspec.rb', line 22

def agents(agents)
  @agents = agents
end

#executeObject



75
76
77
# File 'lib/bozo/test_runners/mspec.rb', line 75

def execute
  execute_command :mspec, [runner_path] << runner_args
end

#platform(platform) ⇒ Object



10
11
12
# File 'lib/bozo/test_runners/mspec.rb', line 10

def platform(platform)
  @platform = platform
end

#project(path) ⇒ Object



14
15
16
# File 'lib/bozo/test_runners/mspec.rb', line 14

def project(path)
  @projects << path
end

#report_path(path) ⇒ Object



18
19
20
# File 'lib/bozo/test_runners/mspec.rb', line 18

def report_path(path)
  @report_path = path
end

#runner_argsObject

Returns the arguments required for the runner’s executable.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bozo/test_runners/mspec.rb', line 50

def runner_args
  args = []

  @projects.each do |project|
    expand_and_glob('temp', 'msbuild', project, '**', "#{project}.dll").each do |test_dll|
      args << "\"#{test_dll}\""
    end
  end

  # If @agents is defined and not 0
  if @agents.to_i > 0
    args << "--agents=#{@agents}"
  end

  report_path = @report_path
  report_path = expand_path('temp', 'mspec', "#{Time.now.to_i}-mspec-report.xml") unless report_path

  # Ensure the directory is there because mspec won't make it
  FileUtils.mkdir_p File.dirname(report_path)

  args << "--xml \"#{report_path}\""

  args
end

#runner_pathObject

Returns the path to the runner’s executable.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bozo/test_runners/mspec.rb', line 33

def runner_path
  exe_name = 'mspec-clr4.exe'

  mspec_runners = expand_and_glob('packages', 'Machine.Specifications*', 'tools', exe_name)
  raise mspec_runner_not_found if mspec_runners.empty?
  raise multiple_runners_found if mspec_runners.size > 1

  mspec_runner = mspec_runners.first

  log_debug "Found runner at #{mspec_runner}"

  mspec_runner
end

#to_sObject



26
27
28
# File 'lib/bozo/test_runners/mspec.rb', line 26

def to_s
  "Run tests with mspec against projects #{@projects}"
end