Mock

The ability to mock commands is a prominent feature of Pester. Mocking is used to reduce the scope of a set of tests.

Creating a Mock overrides a command by taking a partial copy. The copy includes the param and dynamic param blocks, but excludes the any command implementation.

Mocks can be created under Describe or Context keywords.

Commands are mocked using the Mock keyword:

Mock Get-Date 

If a command returns a value, a body can be defined for the Mock to simulate the normal operation of the command. In the following example, the string 01/01/2017 is returned in place of any normal response from Get-Date:

Mock Get-Date { 
'01/01/2017' 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.133.49