Unit test a module
The pdk test unit
command runs all the unit tests in your module.
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.
- From the command line, change into the module's
directory with
cd <MODULE_NAME>
- 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.