DEV Community

Discussion on: Unit testing in PowerShell, introduction to Pester

Collapse
shengeveld profile image
shengeveld

Solved!

The issue seemed to be session related. When I define the Get-AzResource function in the BeforeAll, it works like a charm.


BeforeAll {
    function Get-AzResource($name) { 
        $KeyObject = [PSCustomObject]@{
            ResourceGroupName = "RG100-O"
        }
        Return $KeyObject
    } 
}

Describe 'Utility Unit Tests' -Tag 'unit' {

    It " Retrieves storage context for a given storage account" {