February 2019
Intermediate to advanced
626 pages
15h 51m
English
When testing commands that work with the filesystem, Pester provides TestDrive. TestDrive is a temporary folder created in the current user's temporary directory.
The folder is created when Describe runs, and is destroyed afterwards.
Using TestDrive simplifies the setup process for the Remove-StaleFile function; for example, BeforeAll might become the following:
BeforeAll {
$extensions = '.txt', '.log', '.doc'
Push-Location 'TestDrive:\'
}
AfterAll becomes the following:
AfterAll {
Pop-Location
}
In the event that a command cannot work with the TestDrive label, as is the case with .NET types and methods, as well as non-PowerShell commands, the full path can be discovered by using Get-Item. This can be executed anywhere inside ...
Read now
Unlock full access