New-​Fixture

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

Syntax

New-Fixture
   [[-Path] <String>]
   [-Name] <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 {

}

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

$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") . "$here\$sut"

Describe "Clean" {

It "does something useful" {
    $false | Should Be $true
}

}

Examples

-------------------------- EXAMPLE 1 --------------------------

New-Fixture -Name Clean

Creates the scripts in the current directory.

-------------------------- EXAMPLE 2 --------------------------

New-Fixture C:\Projects\Cleaner Clean

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

-------------------------- EXAMPLE 3 --------------------------

New-Fixture Cleaner Clean

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

Required Parameters

-Name

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

Type:String
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-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:String
Position:1
Default value:$PWD
Accept pipeline input:False
Accept wildcard characters:False