Skip to main content
Version: v5

New-Fixture

This page was generated

Contributions are welcome in Pester v5-repo.

SYNOPSIS​

This function generates two scripts, one that defines a function and another one that contains its tests.

SYNTAX​

New-Fixture [-Name] <string> [[-Path] <string>]

DESCRIPTION​

This function generates two scripts, one that defines a function and another one that contains its tests. The files are by default placed in the current directory and are called and populated as such:

The script defining the function: .\Clean.ps1:

function Clean {
throw [NotImplementedException]'Clean is not implemented.'
}

The script containing the example test .\Clean.Tests.ps1:

BeforeAll {
.
$PSCommandPath.Replace('.Tests.ps1', '.ps1')
}

Describe "Clean" {
It "Returns expected output" {
Clean | Should -Be "YOUR_EXPECTED_VALUE"
}
}

EXAMPLES​

EXAMPLE 1​

New-Fixture -Name Clean

Creates the scripts in the current directory.

EXAMPLE 2​

New-Fixture Clean C:\Projects\Cleaner

Creates the scripts in the C:\Projects\Cleaner directory.

EXAMPLE 3​

New-Fixture -Name Clean -Path Cleaner

Creates a new folder named Cleaner in the current directory and creates the scripts in it.

PARAMETERS​

-Name​

Defines the name of the function and the name of the test to be created.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Path​

Defines path where the test and the function should be created, you can use full or relative path. If the parameter is not specified the scripts are created in the current directory.

Type: System.String
DefaultValue: $PWD
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: