Class: XUnitTestRunner

Inherits:
Object
  • Object
show all
Includes:
Albacore::RunCommand, Albacore::Task
Defined in:
lib/albacore/xunittestrunner.rb

Constant Summary collapse

TaskName =
:xunit

Instance Attribute Summary collapse

Attributes included from Albacore::RunCommand

#command, #working_directory

Attributes included from Logging

#current_log_device, #logger

Instance Method Summary collapse

Methods included from Albacore::RunCommand

#get_command, #run_command

Methods included from AttrMethods

#attr_array, #attr_hash

Methods included from Albacore::Task

clean_dirname, create_rake_task, include_config, included

Methods included from UpdateAttributes

#<<, #update_attributes

Methods included from YAMLConfig

#configure, #load_config_by_task_name

Methods included from Logging

#create_logger, #log_device=, #log_level, #log_level=

Methods included from Failure

#fail_with_message

Constructor Details

#initialize(command = nil) ⇒ XUnitTestRunner

Returns a new instance of XUnitTestRunner.



11
12
13
14
15
16
# File 'lib/albacore/xunittestrunner.rb', line 11

def initialize(command=nil)
  @options=[]
  super()
  update_attributes Albacore.configuration.xunit.to_hash
  @command = command unless command.nil?
end

Instance Attribute Details

#html_outputObject

Returns the value of attribute html_output.



8
9
10
# File 'lib/albacore/xunittestrunner.rb', line 8

def html_output
  @html_output
end

#skip_test_failObject

Returns the value of attribute skip_test_fail.



8
9
10
# File 'lib/albacore/xunittestrunner.rb', line 8

def skip_test_fail
  @skip_test_fail
end

Instance Method Details

#build_html_outputObject



52
53
54
55
# File 'lib/albacore/xunittestrunner.rb', line 52

def build_html_output			
  fail_with_message 'Directory is required for html_output' if !File.directory?(File.expand_path(@html_output))
  "/html \"#{File.join(File.expand_path(@html_output),"%s.html")}\""
end

#executeObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/albacore/xunittestrunner.rb', line 38

def execute()    		
  @assemblies = [] if @assemblies.nil?
  @assemblies << @assembly unless @assembly.nil?
  fail_with_message 'At least one assembly is required for assemblies attr' if @assemblies.length==0	
  failure_message = 'XUnit Failed. See Build Log For Detail'		
  
  @assemblies.each do |assm|
    command_params = get_command_parameters.collect{ |p| p % File.basename(assm) }
    command_params.insert(0,assm)	
    result = run_command "XUnit", command_params.join(" ")
    fail_with_message failure_message if !result && (!@skip_test_fail || $?.exitstatus > 1)
  end       
end

#get_command_lineObject



22
23
24
25
26
27
28
29
# File 'lib/albacore/xunittestrunner.rb', line 22

def get_command_line
  command_params = []
  command_params << @command
  command_params << get_command_parameters
  commandline = command_params.join(" ")
  @logger.debug "Build XUnit Test Runner Command Line: " + commandline
  commandline
end

#get_command_parametersObject



31
32
33
34
35
36
# File 'lib/albacore/xunittestrunner.rb', line 31

def get_command_parameters
  command_params = []	
  command_params << @options.join(" ") unless @options.nil?
  command_params << build_html_output unless @html_output.nil?
  command_params
end

#skip_test_failuresObject



18
19
20
# File 'lib/albacore/xunittestrunner.rb', line 18

def skip_test_failures
  @skip_test_fail = true
end