Skip to content

Commit

Permalink
Dont publish tests (#15)
Browse files Browse the repository at this point in the history
* Refactoring Script Validation Tests naming convention

Changing the naming convention from .Tests.ps1 to
.ScriptValidationTest.ps1 to differentiate unit tests from script
validation tests

* Don't include Pester unit tests in the build artefact
  • Loading branch information
paulmarsy committed Apr 16, 2016
1 parent f966a50 commit 463a4e5
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OctopusStepTemplateCi.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<copyright>(c) 2016 ASOS, licensed under Apache 2.0 License.</copyright>
</metadata>
<files>
<file src="OctopusStepTemplateCi\**\*.*" target="" />
<file src="OctopusStepTemplateCi\**\*.*" target="" exclude="**\*.Tests.ps1"/>
<file src="LICENSE*" target="" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ function Invoke-OctopusScriptTestSuite {
-SuppressPesterOutput:$SuppressPesterOutput

Invoke-PesterForTeamCity -TestName $_.Name `
-Script @{ Path = (Join-Path (Get-ScriptValidationTestsPath) "\Generic\*.Tests.ps1"); Parameters = @{ sut = $_.FullName; TestResultsFile = $testResultsFile; Settings = $TestSettings } } `
-Script @{ Path = (Join-Path (Get-ScriptValidationTestsPath) "\Generic\*.ScriptValidationTest.ps1"); Parameters = @{ sut = $_.FullName; TestResultsFile = $testResultsFile; Settings = $TestSettings } } `
-TestResultsFile (Join-Path $ResultFilesPath $_.Name.Replace(".ps1", ".generic.TestResults.xml")) `
-SuppressPesterOutput:$SuppressPesterOutput

if ($_.Name -like $ScriptModuleFilter) {
Invoke-PesterForTeamCity -TestName $_.Name `
-Script @{ Path = (Join-Path (Get-ScriptValidationTestsPath) "\ScriptModules\*.Tests.ps1"); Parameters = @{ sut = $_.FullName; TestResultsFile = $testResultsFile; Settings = $TestSettings } } `
-Script @{ Path = (Join-Path (Get-ScriptValidationTestsPath) "\ScriptModules\*.ScriptValidationTest.ps1"); Parameters = @{ sut = $_.FullName; TestResultsFile = $testResultsFile; Settings = $TestSettings } } `
-TestResultsFile (Join-Path $ResultFilesPath $_.Name.Replace(".ps1", ".script-module.TestResults.xml")) `
-SuppressPesterOutput:$SuppressPesterOutput
}
elseif ($_.Name -like $StepTemplateFilter) {
Invoke-PesterForTeamCity -TestName $_.Name `
-Script @{ Path = (Join-Path (Get-ScriptValidationTestsPath) "\StepTemplates\*.Tests.ps1"); Parameters = @{ sut = $_.FullName; TestResultsFile = $testResultsFile; Settings = $TestSettings } } `
-Script @{ Path = (Join-Path (Get-ScriptValidationTestsPath) "\StepTemplates\*.ScriptValidationTest.ps1"); Parameters = @{ sut = $_.FullName; TestResultsFile = $testResultsFile; Settings = $TestSettings } } `
-TestResultsFile (Join-Path $ResultFilesPath $_.Name.Replace(".ps1", ".step-template.TestResults.xml")) `
-SuppressPesterOutput:$SuppressPesterOutput
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'

Describe "New-ScriptValidationTest" {
It "Should throw an exception if the script validation test exists" {
New-Item "TestDrive:\test.Tests.ps1" -ItemType File | Out-Null
New-Item "TestDrive:\test.ScriptValidationTest.ps1" -ItemType File | Out-Null

{ New-ScriptValidationTest -Name "test" -Path "TestDrive:\" } | Should Throw
}

It "Should create a new script validation test file" {
New-ScriptValidationTest -Name "test1" -Path "TestDrive:\"

"TestDrive:\test1.Tests.ps1" | Should Exist
"TestDrive:\test1.ScriptValidationTest.ps1" | Should Exist
}

It "Should output a message to the user" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function New-ScriptValidationTest {
[Parameter(Mandatory=$false)][ValidateScript({ Test-Path $_ })][System.String]$Path = $PWD
)

$fileName = Join-Path $Path ("{0}.Tests.ps1" -f ($Name -replace '\s', '-'))
$fileName = Join-Path $Path ("{0}.ScriptValidationTest.ps1" -f ($Name -replace '\s', '-'))

if (Test-Path $fileName) {
throw "Script Validation Test file '$fileName' already exists"
Expand Down

0 comments on commit 463a4e5

Please sign in to comment.