Unit test a module

The pdk test unit command runs all the unit tests in your module.

Before you begin:

Ensure that the /spec/ directory contains the unit tests you want to run. Unit tests generated by PDK test only whether the manifest compiles on the module's supported operating systems, and you can write tests that test whether your code correctly performs the functions you expect it to.

  1. From the command line, change into the module's directory with cd <MODULE_NAME>
  2. Run pdk test unit

    You can customize unit test execution by using command-line options with PDK. Here are some common scenarios:

    pdk test unit --tests=<TEST1>,<TEST2>

    To unit test against a specific major version of Puppet, add a version option flag. For example. To test against Puppet 7, run:

    pdk test unit --puppet-version 7

Results

PDK reports what Ruby and Puppet versions it is testing against, and after tests are completed, test results. For a complete list of command options and usage information, see the PDK command reference.