The Pester Book by Adam Bertram

The Pester Book by Adam Bertram

Author:Adam Bertram [Adam Bertram]
Language: eng
Format: epub, pdf
Publisher: leanpub.com
Published: 2017-04-14T00:00:00+00:00


To remedy this, let’s create a module with “stubbed” commands containing only those functions that you intend to mock. These commands have the same names as the real ones. You’ll still call it AcmeModule with the same function names, but you’ll replace the “real” code inside with a simple throw statement that lets me know you ran the “stubbed” functions.

function Check-ThatThing { param() throw 'Do-CheckThatThing' }

I then add this fake module to the module path. PowerShell sees the same function that you intend to mock, but the code inside is a simple throw statement.

PS> Get-Command -Module AcmeModule CommandType Name Version Source ----------- ---- ------- ------ Function Check-ThatThing 0.0 AcmeModule PS> Get-Content function:Check-ThatThing param() throw 'Check-ThatThing'



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.