Invoke-Pester using Scriptblock instead of files?

94 views
Skip to first unread message

Justin Grote

unread,
Feb 9, 2016, 2:37:35 PM2/9/16
to Pester
Hello,

Is there any way to do something like this and skip the hassle of writing out my tests to a file first? I'm working on dynamically generating tests to check operations, similar to the Operations Validation Framework. I know I can run the command directly but I want the nice output provided by invoke-pester -passthrough rather than write-host because I plan to output it to an excel.

I was hoping to do something like:
$PesterTestBlock = {Describe "Host Networking {It "Returns True" { $true } }

$PesterTestBlock | invoke-pester -passthrough

So is there a way to do this? SO far I can seem to only get Pester to run a script if it exists in a file, and I'm hoping to do this in Azure automation so writing it out to a temp file and reading it back in is a little bit of a hassle. 

Just wanted to see if there was a better way. Thanks for any input.

Dave Wyatt

unread,
Feb 9, 2016, 3:16:07 PM2/9/16
to Pester
Not yet, but that would be pretty easy to add as a feature, and wouldn't even bloat the interface.  Please log it as an issue over on GitHub.  :)

For now, though, you'll need to write to a temp file.
Reply all
Reply to author
Forward
0 new messages