From the command line:
> test-common help > test-common config > edit t/common.yaml > test-common update
Optionally, in your Module::Install based Makefile.PL:
use inc::Module::Install; ... # Keep common tests up to date test_common_update;
There are many module unit tests that are either exactly the same or slightly different, from dist to dist. Test::Common is a framework for distributing and sharing these common tests. (The hope is...) By having many authors contribute to common test pools, not only will it be easier to write common tests fast, it will help expose where specific tests need to be written, and common ways to set these tests up.
As a module author, you maintain a configuration file called
t/common.yaml, which contains information on all the common tests you want to use. These tests can come from Common::Test or any other module that distributes tests in the same way.
The common test scripts are files under the share/ directory. These files are actually Template Toolkit templates. Test::Common renders the templates into real test files (using data from t/common.yaml) every time you run the command
When you run:
you get an example
t/common.yaml file. Edit it. There are comments inside exlaining the basics. For a given entry, like:
- test: foo-bar.t
all the data in that hash gets passed to Template Toolkit to render the test's template. Simple.
To rename a test, do:
- test: foo-bar.t name: test-foo-bar.t
To create a package of your own common tests, put .t files into a share directory, so they get installed by
make install, et al. Then other authors can add your test package to the 'sources' list of their
Since Test::Common tests are always generated, it is your choice whether or not to commit the rendered tests. The only file you really ever need is
The config file has a
clean setting that allows you to control what:
does. If you use the Module::Install plugin then you can just do: