Skip to content

Instantly share code, notes, and snippets.

@AnthonyMastrean
Last active October 8, 2015 14:07
Show Gist options
  • Save AnthonyMastrean/3342412 to your computer and use it in GitHub Desktop.
Save AnthonyMastrean/3342412 to your computer and use it in GitHub Desktop.
MSpec + Rake + TeamCity
# Find all spec assemblies, lazy.
mspec_assemblies = FileList['bin/Release/*.Specs.dll']
mspec_results = mspec_assemblies.pathmap("%X.results.xml")
# Try to solve the TeamCity build log problem by quieting the service messages
# and, instead, generating a test result file per assembly. The console messages
# are probably still useful (so do not include '--silent').
task :generate_mspec_tasks do
mspec_assemblies.zip(mspec_results) do |name, result|
mspec name do |mspec|
mspec.options [
'--no-teamcity-autodetect',
"--xml '#{result}'" ]
mspec.assemblies name
end
end
end
# Try to publish the results all at once, instead of interleaved on the console
# using service messages. PROBLEM: The mspec results file is not accepted. It's
# not in the expected format (see 'nunit'). I could XSLT it?!
task :publish_mspec_results do
mspec_results.each { |x| puts "##teamcity[importData type='mspec' path='#{x}']" }
end
# Make a multitask dependent on all the assembly/task names so they're run in parallel
multitask :run_mspec => mspec_assemblies
# This should cause the correct order of task generation and lazy list evaluation
task :mspec => [ :generate_mspec_tasks, :run_mspec, :publish_mspec_results ]
@AnthonyMastrean
Copy link
Author

Oh snap, maybe I'll just suppress service messages?

##teamcity[enableServiceMessages]
##teamcity[disableServiceMessages]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment