forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about_TestDrive.help.txt
40 lines (33 loc) · 1.09 KB
/
about_TestDrive.help.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
TOPIC
TestDrive
SYNOPSIS
A PSDrive for file activity limited to the scope of a singe Describe or
Context block.
DESCRIPTION
A test may need to work with file operations and validate certain tyes of
file activities. It is usually desirable not to perform file activity tests
that will produce side effects outside of an individual test. Pester
creates a PSDrive inside the user's temporary drive that is accesible via a
names PSDrive TestDrive:. Pester will remove this drive afterthe test
completes. You may use this drive to isolate the file operations of your
test to a temporary store.
EXAMPLE
function Add-Footer($path, $footer) {
Add-Content $path -Value $footer
}
Describe "Add-Footer" {
$testPath="TestDrive:\test.txt"
Set-Content $testPath -value "my test text."
Add-Footer $testPath "-Footer"
$result = Get-Content $testPath
It "adds a footer" {
(-join $result).Should.Be("my test text.-Footer")
}
}
When this test completes, the contents of the TestDrive PSDrive will
be removed.
SEE ALSO
Context
Describe
It
about_Should