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
    July 17, 2019 12:21

    Could someone please reply to the previous 2 comments?

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

  • David Wallis commented
    July 12, 2019 15:36

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

  • Jeff Davis commented
    May 11, 2019 01:39

    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
    April 25, 2019 13:39

    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/