Module: Rutema::Elements::MSTest
- Defined in:
- lib/rutema/elements/win32.rb
Overview
Elements to drive MSTest
Instance Method Summary collapse
-
#element_mstest(step) ⇒ Object
Calls an MSTest assembly.
Instance Method Details
#element_mstest(step) ⇒ Object
Calls an MSTest assembly.
Requires the attribute assembly pointing to the assembly to execute. Path can be relative to the specification file.
Configuration
Requires a configuration.tool entry with :name=>“mstest” and a :configuration entry pointing to a hash containing the configuration parameters.
Configuration parameters are: :path - the path to the mstest utility. Required :shared_path - a :local=>“localpath”,:share=>“sharepath” entry. Optional :assembly_root - the path relative to which the assembly paths are calculated. If it’s not defined then the paths are calculated relative to the specification file. Optional
Example Configuration Entry
configuration.tool=:name=>“mstest”,:configuration=>{:path=>“/to/mstest.exe”,assembly_root=>“c:/assemblies”}
Extras
The shared_path hash is a workaround for calling assemblies when the current working directory is on a shared drive (i.e. when running certain tasks in a TFS build)
An example will illustrate it’s usage better:
:share=>“//host/tests”,:local=>“c:/tests” will result in :share being substituted with :local on the assembly pathname so \\\host\\tests\\assembly.dll becomes c:\\tests\\assembly.dll
Note that entries should be defined with ‘/’ instead of ‘\\’.
Examples
<mstest assembly=“tests.dll”/>
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/rutema/elements/win32.rb', line 186 def element_mstest step raise Rutema::ParserError,"Missing required attribute 'assembly'" unless step.has_assembly? raise Rutema::ParserError,"Missing tool configuration for mstest (no configuration.tool entry)" unless @configuration.tools.mstest && @configuration.tools.mstest[:configuration] cfg=@configuration.tools.mstest[:configuration].dup path_to_util=cfg[:path] raise Rutema::ParserError,"Cannot find mstest in '#{path_to_util}'" unless File.exists?(path_to_util) if step.has_assembly_root? cfg[:assembly_root]=step.assembly_root else cfg[:assembly_root]=Dir.pwd end #icalculate the paths relative to the assembly_root assembly_path=adjust_with_root_path(step.assembly,cfg[:assembly_root],step) #check to see if we apply the workaround shared_path=cfg[:shared_path] if shared_path raise Rutema::ParserError,"Missing :share key for shared_path configuration" unless shared_path[:share] raise Rutema::ParserError,"Missing :local key for shared_path configuration" unless shared_path[:local] @logger.debug("Assembly path is '#{assembly_path}'") @logger.debug("Shared path manipulation (#{shared_path[:share]}=>#{shared_path[:local]}") assembly_path.gsub!(shared_path[:share],shared_path[:local]) @logger.debug("Assembly path is now '#{assembly_path}'") end #make the path windows compatible assembly_path.gsub!('/',"\\\\") #create the command line and the command instance cmdline="\"#{path_to_util}\" /testcontainer:\"#{assembly_path}\"" @logger.debug("Parsed mstest call as '#{cmdline}'") step.cmd=Patir::ShellCommand.new(:cmd=>cmdline,:working_directory=>File.dirname(assembly_path)) return step end |