VMware PowerCLI

The Best User Interface for your VMware Datacenter!

Pester support : add an option to create a "mock" PowerCLI .Net object with values assigned to properties

In Pester one can mock an object, and that also works for the PowerCLI .Net objects.
But the New-MockObject cmdlet creates an empty object, and since most properties in PowerCLI .Net objects are read-only, that doesn't offer the possibility to mock such objects with specific values.

It would be handy if there was a new() method for PowerCLI .Net objects that would allow to pre-populate specific properties.

This would allow to write decent Pester tests for PowerCLI scripts.

  • Luc Dekens
  • Jan 24 2018
  • Shipped
  • Attach files
  • Luc Dekens commented
    17 Jul, 2019 12:21pm

    Could someone please reply to the previous 2 comments?

    Is it 'Shipped' or not?
    And if it is, where?

  • David Wallis commented
    12 Jul, 2019 03:36pm

    Really need this too - any pointers as to where it shipped to?

  • Jeff Davis commented
    11 May, 2019 01:39am

    I see this has been set to shipped, does that mean that this is actually going to be in the next release? Or is this declaring that the dsc module mocks are good enough?

  • Alain Tanguy commented
    25 Apr, 2019 01:39pm

    Pester is the main Test Engine for Powershell, Powercli should get the attention it deserve regarding this feature.I just want to say a million thanks to Luc D for his Pester Blog Article http://www.lucd.info/2019/02/01/dscr-and-pester-testing/