Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
Removed the default values of the parameter ExcludeTag in favor of us…
Browse files Browse the repository at this point in the history
…ing opt-in (#277)

- Removed the default values of the parameter `ExcludeTag` in favor of using
  opt-in. Default is that those tests are opt-out, and must be opt-in (issue #274).
- Excluding tag 'Examples' when calling `Invoke-AppveyorTestScriptTask` since
  this repository will never have examples.
  • Loading branch information
johlju committed Aug 11, 2018
1 parent 60efdea commit 6b03803
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 52 deletions.
3 changes: 1 addition & 2 deletions AppVeyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function Invoke-AppveyorInstallTask
.PARAMETER ExcludeTag
This is the list of tags that will be used to prevent tests from being run if
the tag is set in the describe block of the test.
This wll default to 'Examples' and 'Markdown'.
.PARAMETER HarnessModulePath
This is the full path and filename of the test harness module.
Expand Down Expand Up @@ -161,7 +160,7 @@ function Invoke-AppveyorTestScriptTask

[Parameter(ParameterSetName = 'Default')]
[String[]]
$ExcludeTag = @('Examples', 'Markdown'),
$ExcludeTag,

[Parameter(ParameterSetName = 'Harness')]
[String]
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ that the markdown files are correct.
The 'markdown' tests can be excluded when running pester by using:

```PowerShell
Invoke-Pester -ExcludeTag 'Markdown'
Invoke-Pester -ExcludeTag @('Markdown')
```

It is possible to override the default behavior of the markdown validation test.
Expand All @@ -118,7 +118,7 @@ This causes them to behave as extra integration tests.
The 'example' tests can be excluded when running pester by using:

```PowerShell
Invoke-Pester -ExcludeTag 'Example'
Invoke-Pester -ExcludeTag @('Example')
```

When a repository is opted-in to example testing, each example file in the 'Examples'
Expand Down Expand Up @@ -922,6 +922,11 @@ Contributors that add or change an example to be published must make sure that
* Migrate Pester Test Syntax from v3 -> v4
([issue #199](https://github.com/PowerShell/DscResource.Tests/issues/199)).
* Activate GitHub App Review Me.
* Removed the default values of the parameter `ExcludeTag` in favor of using
opt-in. Default is that those tests are opt-out, and must be opt-in
([issue #274](https://github.com/PowerShell/DscResource.Tests/issues/274)).
* Excluding tag 'Examples' when calling `Invoke-AppveyorTestScriptTask` since
this repository will never have examples.
### 0.2.0.0
Expand Down
119 changes: 72 additions & 47 deletions Tests/Unit/AppVeyor.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ InModuleScope $script:ModuleName {

{ Invoke-AppveyorTestScriptTask @testParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 1
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 1
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1
Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1 -Scope It
}
}

Expand Down Expand Up @@ -212,17 +212,21 @@ InModuleScope $script:ModuleName {
Mock -CommandName Invoke-Pester -MockWith { return $mockTestResult }
}

AfterEach {
Assert-MockCalled -CommandName Invoke-Pester -Exactly -Times 1 -Scope It
}

Context 'When called with default values' {
It 'Should not throw exception and call the correct mocks' {
{ Invoke-AppveyorTestScriptTask } | Should -Not -Throw

Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 0
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 0
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 0
Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 0 -Scope It
}

Context 'When configuration needs a module to compile' {
Expand All @@ -240,8 +244,8 @@ InModuleScope $script:ModuleName {
It 'Should not throw exception and call the correct mocks' {
{ Invoke-AppveyorTestScriptTask } | Should -Not -Throw

Assert-MockCalled -CommandName Get-ResourceModulesInConfiguration -Exactly -Times 1
Assert-MockCalled -CommandName Install-DependentModule -Exactly -Times 1
Assert-MockCalled -CommandName Get-ResourceModulesInConfiguration -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Install-DependentModule -Exactly -Times 1 -Scope It
}
}
}
Expand All @@ -255,13 +259,34 @@ InModuleScope $script:ModuleName {

{ Invoke-AppveyorTestScriptTask @testParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 1
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 1
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 1
Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 1 -Scope It
}
}

Context 'When called with the parameters ExcludeTag' {
It 'Should not throw exception and call the correct mocks' {
$testParameters = @{
ExcludeTag = @('Markdown')
}

{ Invoke-AppveyorTestScriptTask @testParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName Invoke-Pester -ParameterFilter {
$ExcludeTag[0] -eq 'Markdown'
} -Exactly -Times 1
}
}

Expand All @@ -285,13 +310,13 @@ InModuleScope $script:ModuleName {

{ Invoke-AppveyorTestScriptTask @testParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 0
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 0
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 0
Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 0 -Scope It
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 0 -Scope It
}
}

Expand Down Expand Up @@ -377,47 +402,47 @@ InModuleScope $script:ModuleName {

{ Invoke-AppveyorTestScriptTask @testParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 3
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 9
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 1
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 1
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 5
Assert-MockCalled -CommandName Get-Content -Exactly -Times 2
Assert-MockCalled -CommandName Out-TestResult -Exactly -Times 2
Assert-MockCalled -CommandName Out-MissedCommand -Exactly -Times 2
Assert-MockCalled -CommandName Add-AppveyorTest -Exactly -Times 3 -Scope It
Assert-MockCalled -CommandName Push-TestArtifact -Exactly -Times 9 -Scope It
Assert-MockCalled -CommandName Export-CodeCovIoJson -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Invoke-UploadCoveCoveIoReport -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName New-DscSelfSignedCertificate -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Initialize-LocalConfigurationManager -Exactly -Times 1 -Scope It
Assert-MockCalled -CommandName Write-Warning -Exactly -Times 5 -Scope It
Assert-MockCalled -CommandName Get-Content -Exactly -Times 2 -Scope It
Assert-MockCalled -CommandName Out-TestResult -Exactly -Times 2 -Scope It
Assert-MockCalled -CommandName Out-MissedCommand -Exactly -Times 2 -Scope It
Assert-MockCalled -CommandName New-Container -ParameterFilter {
$Name -eq $containerName1
} -Exactly -Times 1
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName New-Container -ParameterFilter {
$Name -eq $containerName2
} -Exactly -Times 1
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Start-Container -ParameterFilter {
$ContainerIdentifier -eq $containerIdentifier1
} -Exactly -Times 1
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Start-Container -ParameterFilter {
$ContainerIdentifier -eq $containerIdentifier2
} -Exactly -Times 1
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Wait-Container -ParameterFilter {
$ContainerIdentifier -eq $containerIdentifier1
} -Exactly -Times 1
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Wait-Container -ParameterFilter {
$ContainerIdentifier -eq $containerIdentifier2
} -Exactly -Times 1
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Copy-ItemFromContainer -ParameterFilter {
$ContainerIdentifier -eq $containerIdentifier1
} -Exactly -Times 3
} -Exactly -Times 3 -Scope It

Assert-MockCalled -CommandName Copy-ItemFromContainer -ParameterFilter {
$ContainerIdentifier -eq $containerIdentifier2
} -Exactly -Times 3
} -Exactly -Times 3 -Scope It
}

Context 'When container reports an error' {
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build: false
test_script:
- ps: |
Invoke-AppveyorTestScriptTask `
-ExcludeTag @() `
-ExcludeTag @('Examples') `
-CodeCoverage `
-CodeCovIo
Expand Down

0 comments on commit 6b03803

Please sign in to comment.