Perl Script Snippets
Jump to navigation
Jump to search
Canonical Module Format
use strict;
use warnings;
package MyTests;
use base qw(STRIDE::Test);
use STRIDE::Test;
sub test_one : Test
{
ASSERT_TRUE(1);
}
sub test_two : Test
{
ASSERT_TRUE(0);
}
1;
Subroutine attributes to declare test methods and fixtures
sub a_test : Test {
# test method
}
sub startup_method : Test(startup) {
# startup fixturing
}
sub shutdown_method : Test(shutdown) {
# shutdown fixturing
}
sub setup_method : Test(setup) {
# setup fixturing
}
sub teardown_method : Test(teardown) {
# teardown fixture
}
Test Module Including POD Documentation
package MyTests;
use base qw(STRIDE::Test);
use STRIDE::Test;
=head1 NAME
MyTests - example tests
=head1 DESCRIPTION
This is MyTests_1, a deeply funky piece of Perl code.
=head1 METHODS
=cut
=head2 test_one
this is a simple passing test.
=cut
sub test_one : Test
{
ASSERT_TRUE(1);
}
=head2 test_two
this is a simple passing test.
=cut
sub test_two : Test
{
ASSERT_TRUE(0);
}
1;