| 1 |
=begin |
| 2 |
|
| 3 |
=head1 Adding Tests |
| 4 |
|
| 5 |
For now, this just lists a few general conventions that will make it easier |
| 6 |
for everyone to work together to fill out the test suite. |
| 7 |
|
| 8 |
|
| 9 |
=head2 Test File Name |
| 10 |
|
| 11 |
Test files should be named as follows: |
| 12 |
|
| 13 |
(01-09)-foo.t Basic tests of low-level infrastructure |
| 14 |
(10-49)-lib-plumage-foo.t Tests for Plumage::Foo libraries, in layer order |
| 15 |
(50-99)-plumage-type.t Various types of tests for the plumage CLI tool |
| 16 |
|
| 17 |
|
| 18 |
=head2 Test File Layout |
| 19 |
|
| 20 |
Each new test file should follow the same basic layout as seen in the |
| 21 |
F<t/03-util.t> test file -- a standard C<MAIN()> sub that loads the Parrot |
| 22 |
C<Test::More> implementation and the library (if any) that will be tested, |
| 23 |
and then hands off to a basic C<run_tests()> sub that just sets the C<plan> |
| 24 |
and calls each actual testing function in sequence. |
| 25 |
|
| 26 |
These testing functions should be named C<test_>I<whatever>C<()>, where |
| 27 |
I<whatever> is the name of the function, variable, command, etc. that is |
| 28 |
being tested, and they should follow right after C<run_tests()>, with any |
| 29 |
helper functions right after the functions they help. |
| 30 |
|
| 31 |
Testing functions should appear in the same order in C<run_tests()> that |
| 32 |
they appear in the rest of the file, and this order should also roughly match |
| 33 |
the order the tested items appear in the library or program source; of course, |
| 34 |
sometimes it will make more sense to test things slightly out of order |
| 35 |
(testing a file write function before a file read function, for instance, |
| 36 |
even though the read function appears first in the library source). |
| 37 |
|
| 38 |
|
| 39 |
=head2 Testing Tools |
| 40 |
|
| 41 |
We use Parrot's C<Test::More> implementation, but in a few cases its |
| 42 |
PIR-centric design shows through, and NQP provides better native tools. |
| 43 |
|
| 44 |
In particular: |
| 45 |
|
| 46 |
=over 4 |
| 47 |
|
| 48 |
=item * Instead of C<like()>, please use C<ok()> with native NQP-rx C<$string ~~ /regex/> match. |
| 49 |
|
| 50 |
=item * Instead of C<lives_ok()>, C<dies_ok()>, or C<throws_like()>, please use native NQP-rx C<try {}> and/or C<CATCH {}>. |
| 51 |
|
| 52 |
=back |
| 53 |
|
| 54 |
If you do end up using a C<Test::More> function not already sanity-checked |
| 55 |
in t/01-sanity.t, please add a quick test there as well, just to make sure we |
| 56 |
know what happened if a future Parrot refactor breaks our test suite. |
| 57 |
|
| 58 |
|
| 59 |
=end |