Last active
April 23, 2020 05:01
-
-
Save johlju/d63b54cdb38bf15872e4ccad8a2bf7ca to your computer and use it in GitHub Desktop.
Example Unit Test
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
InModuleScope $script:dscResourceName { | |
Describe 'ResourceName\Get-TargetResource' -Tag 'Get' { | |
BeforeAll { | |
# Mocks for all context blocks. Avoid if possible. | |
} | |
# Context block cannot always be used. | |
Context 'When the system is not in the desired state' { | |
BeforeAll { | |
# Mocks when the system is not in desired state | |
} | |
It 'Should...' { | |
# Test when the system is not in the desired state | |
} | |
} | |
Context 'When the system is the desired state' { | |
BeforeAll { | |
# Mocks when the system is in desired state | |
} | |
It 'Should...' { | |
# Test when the system is in the desired state | |
} | |
} | |
} | |
Describe 'ResourceName\Test-TargetResource' -Tag 'Test' { | |
BeforeAll { | |
# Mocks for all context blocks. Avoid if possible. | |
} | |
Context 'When the system is not in the desired state' { | |
BeforeAll { | |
# Mocks when the system is not in desired state | |
} | |
It 'Should...' { | |
# Test when the system is not in the desired state | |
} | |
} | |
Context 'When the system is the desired state' { | |
BeforeAll { | |
# Mocks when the system is in desired state | |
} | |
It 'Should...' { | |
# Test when the system is in the desired state | |
} | |
} | |
} | |
Describe 'ResourceName\Set-TargetResource' -Tag 'Set' { | |
BeforeAll { | |
# Mocks for all context blocks. Avoid if possible. | |
} | |
Context 'When the system is not in the desired state' { | |
BeforeAll { | |
# Mocks when the system is not in desired state | |
} | |
It 'Should...' { | |
# Test when the system is not in the desired state | |
} | |
} | |
Context 'When the system is the desired state' { | |
BeforeAll { | |
# Mocks when the system is in desired state | |
} | |
It 'Should...' { | |
# Test when the system is in the desired state | |
} | |
} | |
} | |
Describe 'ResourceName\Get-FirstResourceHelperFunction' -Tag 'Helper' { | |
BeforeAll { | |
# Mocks for all context blocks. Avoid if possible. | |
} | |
Context 'When helper function returns state 1' { | |
It 'Should...' { | |
# Test first state of the helper function. | |
} | |
} | |
Context 'When helper function returns state 2' { | |
It 'Should...' { | |
# Test second state of the helper function. | |
} | |
} | |
} | |
Describe 'ResourceName\Get-SecondResourceHelperFunction' -Tag 'Helper' { | |
BeforeAll { | |
# Mocks for all context blocks. Avoid if possible. | |
} | |
Context 'When helper function returns state 1' { | |
It 'Should...' { | |
# Test first state of the helper function. | |
} | |
} | |
Context 'When helper function returns state 2' { | |
It 'Should...' { | |
# Test second state of the helper function. | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment