Created
October 1, 2009 18:40
-
-
Save spraints/199155 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Watch for source changes | |
| watch(/^.*cs$/i) do |m| rake end | |
| # Watch for test output processing changes | |
| watch(/^Rakefile$/i) do |m| rake 'myproject:test' end | |
| def rake(task = 'myproject') | |
| system 'rake', task | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'albacore' | |
| require 'rexml/document' | |
| # Will submit this as a patch when github starts letting me push again. | |
| module Rake | |
| class MSBuildTask | |
| def define | |
| task name do | |
| fail unless @msbuild.build | |
| end | |
| end | |
| end | |
| end | |
| desc 'Build and test MyProject.Tests' | |
| task 'myproject' => %W(myproject:build myproject:test) | |
| namespace 'myproject' do | |
| Configuration = 'Debug' | |
| desc 'Build MyProject.Tests' | |
| Rake::MSBuildTask.new(:build) do |msb| | |
| msb.properties :configuration => Configuration, :platform => 'x86' | |
| msb.targets %W( MyProject_Tests ) | |
| msb.solution = 'MySolution.sln' | |
| end | |
| desc 'Run MyProject.Tests' | |
| task :test do | |
| rm 'results.trx' if File.exist? 'results.trx' | |
| mstest_cmd =%W(mstest | |
| /testcontainer:MyProject.Tests\\bin\\x86\\#{Configuration}\\MyProject.Tests.dll | |
| /runconfig:ContinuousBuild.testrunconfig | |
| /resultsfile:results.trx) | |
| sh(*mstest_cmd) do |ok, status| | |
| process('results.trx') | |
| end | |
| end | |
| def process(results_file) | |
| fail_count = 0 | |
| File.open(results_file) do |file| | |
| xml =REXML::Document.new(file) | |
| xml.elements.each '//UnitTestResult[@outcome="Failed"]' do |e| | |
| puts '' | |
| puts '**********************************' | |
| puts e.attributes['testName'] | |
| puts e.elements['Output/ErrorInfo/Message'].get_text.value | |
| puts e.elements['Output/ErrorInfo/StackTrace'].get_text.value | |
| puts '' | |
| fail_count = fail_count.succ | |
| end | |
| end | |
| fail "#{fail_count} tests failed" if fail_count > 0 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment