The tests folder include all the test script use Pester.
The tests are categorized into two type of tests offline and online
- offline test can be run without real SDN deployment through mock based on sample data collected from SDN deployment.
- online test need to run against SDN deployment
offline\RunTests.ps1is the start script to run all offline tests under offline test folder.online\RunTests.ps1is the start script to run all online tests under online folder.wave1...waveAllinclude all test scripts grouped into different wave. Tests will be executed in order of wave.
- Install latest Pester by
Install-Module -Name Pester -Force -SkipPublisherCheck. More info from Pester Update - The
offline\datafolder include the sample data likeSdnApiResources. The data is loaded into$Global:PesterOfflineTest - Run offline test at offline folder by
.\RunTests.ps1
-
Generate the configuration based on
SdnDiagnosticsTestConfig-Sample.psd1. Do not commit change to include your test environment specific settings. -
Copy the
testsfolder to the test environment and run.\RunTests.ps1 -ConfigurationFile SdnDiagnosticsTestConfig-Sample.psd1
- If your test function can be mocked with sample data, put it under
offlinefolder. Otherwise, this have to be underonlinefolder. - For offline test, sample data can be consumed from
$Global:PesterOfflineTestto write your mock. - The new test script should be named as
*originalscriptname*.Tests.ps1. For example,Diagnostics.Tests.ps1include the tests function for scriptDiagnostics.ps1 - The online test scripts are grouped into different wave to maintain test execution order.
wave1...waveAll. If you don't expect order of test execution, the test script need to be inwaveAllfolder.