Skip to content
Henrik edited this page Aug 21, 2014 · 1 revision

Run tests written with the XUnit test framework.

desc "Run xunit tests"
xunit :test => [:build] do |cmd|
  cmd.command = "path/to/xunitconsole"
  cmd.assembly = "path/to/test/assembly"
  cmd.results_path = {:xml => "path/to/results"}
end

Required Parameters

Command

The location of the xunit console executable.

command = "path/to/xunitconsole"

Assembly

One assembly, containing [Fact]s, for xunit to run. XUnit's console runner supports one assembly per run.

assembly = "path/to/test/assembly"

Optional Parameters

Results Path

The type of output and the location of the file to write: :html, xml, & :nunit. If one assembly is specified, this will be unchanged. If multiple assemblies are specified, the output filename will have the current assembly count appended (1-based), like "out/output_1.html.

results_path = {:xml => "path/to/results"}

Guidance

Multiple Test Assemblies

Unfortunately, you must write a task per test assembly and I don't think you can depend on Rake's FileList because your build might be creating these assemblies and they wouldn't exist at the time you tried to define your tasks...

xunit_assemblies = FileList["path/to/assemblies/with/wildcards"]
xunit_assemblies.each do |name|
  xunit name do |cmd|
    cmd.command = "xunit"
    cmd.assembly = name
    cmd.output_path = {:html => "#{File.basename(name)}.html"}
  end
end
Clone this wiki locally