PSAKE- Gallio–SpecFlow–XUnit–on the build server

This is a quick post to show how to get PowerShell with PSAKE to run Specflow acceptance tests on the build server using Gallio.


The folder with our build scripts looks like this




The environments folder contains all of the configuration files for each environment




Build server process


The build/check-in process is now as follows.

1. Developer checks in.

2. Build server detects changes – cleans everything and then pulls down latest SVN code

3. Cruise control builds code in release mode –> If compile fails –> build fail

4. Unit tests run in place à if any test fails –> build fail

5. On success a new folder with the VERSION number is created      — this is our artefacts

6. This build is then deployed to the integration server and the Acceptance tests are run – Results are output to a folder

7. If the Acceptance tests fails -> build fail

8. On Success the build is packaged for deployment (config files modified for environment)


Cruise control originally calls default.ps1 passing in the environment.

<scriptsDirectory>C:\CCWorking\Phoenix\CodeBase\Build\BuildScripts</scriptsDirectory><!–Scrips folder–>
<buildArgs>-environment:integration</buildArgs><!– Project working folder -workingDir C:\project1\working–>
<description>Phoenix Build</description>


This calls build.ps1

PSAKE tasks include


Task default -depends PrintInformation, CleanEnvironment, Clean, SetupEnvironment, MakeBuild, BuildDatabase, DeployIntegrationBuild, IntegrationTest, DeployBuild, UpdateConfigFiles


To run the acceptance tests using Gallio

The following Powershell function is used:@

Usage for Gallio tests:

Task Test-System -Description “Runs the system tests via Gallio” {
Test-Gallio $proj $configuration $platform $dll “system” “Test.System”
# Test-Gallio “.\src\Test.Unit\Test.Unit.csproj” Release x64 “.\src\Test.Unit\bin\Release\x64\Test.Unit.dll” “unit”
function Test-Gallio($proj, $configuration, $platform, $dll, $report_name, $report_dir, $namespace_filter){
Write-Host “GALLIO TEST proj —  $proj”
Write-Host “GALLIO TEST configuration —  $configuration”
Write-Host “GALLIO TEST platform —  $platform”
Write-Host “GALLIO TEST dll —  $dll”
Write-Host “GALLIO TEST report_name —  $report_name”
Write-Host “GALLIO TEST namespace_filter —  $namespace_filter”

    if ( (Get-PSSnapin -Name Gallio -ErrorAction SilentlyContinue) -eq $null )
Add-PSSnapin Gallio
$result = Run-Gallio $dll -filter Namespace:/$namespace_filter/ -ReportTypes text,html,xml -ReportDirectory $report_dir  -ReportNameFormat $report_name-test-report  #-NoProgress -NoEchoResults
get-content “$report_dir\$report_name-test-report.txt” | Write-Host
Write-Host $result.ResultsSummary
if ($result.Statistics.FailedCount -gt 0) {
Write-Warning “Some unit tests have failed.”
$Error = $result.ResultsSummary
exit $result.ResultCode

Remove-PSSnapin Gallio



From an acceptance test entered into SpecFlow as follows:


On checkin the build will run and output the result of this test in a report called  AcceptanceTests-test-report.html