Testing a DSC Resource

Welcome Forums General PowerShell Q&A Testing a DSC Resource

This topic contains 1 reply, has 2 voices, and was last updated by

5 years, 3 months ago.

  • Author
  • #12985

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    I have implemented several DSC resources but now I need to devise a way to test them. What I found as possible options are:

      Unit testing of the underlying PowerShell code i.e. Get-, Test-, Set-TargetResource methods
      Integration test that starts a VM, applies the DSC resource and asserts whether everything is in place
      Using the WhatIf switch of the Start-DscConfiguration method to look for specific messages – but this not real functional testing
      Using the Test-DscConfiguration to verify that the changes are applied correctly and the machine state is the correct one

    I would like to know whether this is the correct way to test the DSC resource and if there is something better as an approach.

    Thank you in advance.

  • #15313

    Topics: 13
    Replies: 4872
    Points: 1,843
    Helping HandTeam Member
    Rank: Community Hero

    Unit testing as you suggest is probably the best place to start.

The topic ‘Testing a DSC Resource’ is closed to new replies.