Context

Provides logical grouping of It blocks within a single Describe block. Any Mocks defined inside a Context are removed at the end of the Context scope, as are any files or folders added to the TestDrive during the Context block's execution. Any BeforeEach or AfterEach blocks defined inside a Context also only apply to tests within that Context .

Syntax

Context
   [-Name] <String>
   [[-Fixture] <ScriptBlock>]

Description

{{Fill in the Description}}

Examples

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

function Add-Numbers($a, $b) {

return $a + $b }

Describe "Add-Numbers" {

Context "when root does not exist" {
     It "..." { ...

} }

Context "when root does exist" {
    It "..." { ...

} It "..." { ... } It "..." { ... } } }

Required Parameters

-Name

The name of the Context. This is a phrase describing a set of tests within a describe.

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

Optional Parameters

-Fixture

Script that is executed. This may include setup specific to the context and one or more It blocks that validate the expected outcomes.

Type:ScriptBlock
Position:2
Default value:$(Throw "No test script block is provided. (Have you put the open curly brace on the next line?)")
Accept pipeline input:False
Accept wildcard characters:False