Unit test a module
The pdk test unit command runs all the unit tests in your module. Unit tests generated by PDK test only whether the manifest compiles on the module's supported operating systems. To test whether your code correctly performs the functions you expect it to, write additional tests.
-
Ensure that the
/spec/directory contains the unit tests you want to run. -
When default unit test configuration does not meet your requirements, Customize unit and unit acceptance tests .
- From the command line, change into the module's
directory with
cd <MODULE_NAME> -
Run
pdk test unitYou can customize unit test execution by using command-line options with PDK. Here are some common scenarios:
Copypdk 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:
Copypdk 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.






