require File.join(File.dirname(__FILE__), 'support', 'spec_helper') require 'albacore/xunittestrunner' @@xunitpath = File.join(File.dirname(__FILE__), 'support', 'Tools', 'XUnit-v1.5', 'xunit.console.exe') @@test_assembly = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'xunit', 'assemblies', 'TestSolution.XUnitTests.dll') @@output_option = "/out=xunit.results.html" @@working_dir =File.join(File.dirname(__FILE__), 'support','xunit') @@html_output = File.join(@@working_dir,'TestSolution.XUnitTests.dll.html') describe XUnitTestRunner, "the command parameters for an xunit runner" do before :all do xunit = XUnitTestRunner.new(@@xunitpath) xunit.assembly = @@test_assembly xunit.options @@output_option @command_parameters = xunit.get_command_parameters end it "should not include the path to the command" do @command_parameters.should_not include(@@xunitpath) end it "should include the list of options" do @command_parameters.should include(@@output_option) end end describe XUnitTestRunner, "the command line string for an xunit runner" do before :all do xunit = XUnitTestRunner.new(@@xunitpath) xunit.assembly = @@test_assembly xunit.options @@output_option @command_line = xunit.get_command_line @command_parameters = xunit.get_command_parameters.join(" ") end it "should start with the path to the command" do @command_line.split(" ").first.should == @@xunitpath end it "should include the command parameters" do @command_line.should include(@command_parameters) end end describe XUnitTestRunner, "when configured correctly" do before :all do xunit = XUnitTestRunner.new(@@xunitpath) xunit.assembly = @@test_assembly xunit.options '/noshadow' xunit.extend(FailPatch) xunit.log_level = :verbose xunit.execute end it "should execute" do $task_failed.should be_false end end describe XUnitTestRunner, "when multiple assemblies are passed to xunit runner" do before :all do xunit = XUnitTestRunner.new(@@xunitpath) xunit.assemblies = @@test_assembly, @@test_assembly xunit.options '/noshadow' xunit.extend(FailPatch) xunit.log_level = :verbose xunit.execute end it "should execute" do $task_failed.should be_false end end describe XUnitTestRunner, "when zero assemblies are passed to xunit runner" do before :all do xunit = XUnitTestRunner.new(@@xunitpath) xunit.options '/noshadow' xunit.extend(FailPatch) xunit.execute end it "should fail" do $task_failed.should be_true end end describe XUnitTestRunner, "when html_output is specified" do before :each do FileUtils.mkdir @@working_dir xunit = XUnitTestRunner.new(@@xunitpath) xunit.assemblies = @@test_assembly xunit.html_output = File.dirname(@@html_output) xunit.extend(FailPatch) xunit.execute end it "should execute" do $task_failed.should be_false end it "should write output html" do File.exist?(@@html_output).should be_true end after:each do FileUtils.rm_r @@working_dir if File.exist? @@working_dir end end describe XUnitTestRunner, "when html_output is not a directory" do before :each do FileUtils.mkdir @@working_dir strio = StringIO.new xunit = XUnitTestRunner.new(@@xunitpath) xunit.log_level = :verbose xunit.log_device = strio xunit.assemblies = @@test_assembly xunit.html_output = @@html_output xunit.extend(FailPatch) xunit.execute @log_data = strio.string end it "should fail" do $task_failed.should be_true end it "should log a message" do @log_data.should include('Directory is required for html_output') end after:each do FileUtils.rm_r @@working_dir if File.exist? @@working_dir end end