Test::SimpleUnit

Test::SimpleUnit is a simplified Perl unit-testing framework.
Download

Test::SimpleUnit Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Michael Granger
  • Publisher web site:
  • http://search.cpan.org/~ged/Class-Translucent-1.18/lib/Class/Translucent.pm

Test::SimpleUnit Tags


Test::SimpleUnit Description

Test::SimpleUnit is a simplified Perl unit-testing framework. Test::SimpleUnit is a simplified Perl unit-testing framework.SYNOPSIS use Test::SimpleUnit qw{:functions}; runTests( {name => "test1", test => sub {...}}, {name => "testN", test => sub {...}} );EXAMPLE use Test::SimpleUnit qw{:functions}; # If a setup or teardown function fails, skip the rest of the tests Test::SimpleUnit::AutoskipFailedSetup( 1 ); Test::SimpleUnit::AutoskipFailedTeardown( 1 ); my $Instance; my $RequireWasOkay = 0; my @tests = ( # Require the module { name => 'require', test => sub { # Make sure we can load the module to be tested. assertNoException { require MyClass }; # Try to import some functions, generating a custom error message if it # fails. assertNoException { MyClass->import(':myfuncs') } "Failed to import :myfuncs"; # Make sure calling 'import()' actually imported the functions assertRef 'CODE', *::myfunc{CODE}; assertRef 'CODE', *::myotherfunc{CODE}; # Set the flag to let the setup function know the module loaded okay $RequireWasOkay = 1; }, }, # Setup function (this will be run before any tests which follow) { name => 'setup', test => sub { # If the previous test didn't finish, it's untestable, so just skip the # rest of the tests skipAll "Module failed to load" unless $RequireWasOkay; $Instance = new MyClass; }, }, # Teardown function (this will be run after any tests which follow) { name => 'teardown', test => sub { undef $Instance; }, }, # Test the connect() and disconnect() methods { name => 'connect() and disconnect()', test => sub { my $rval; assertNoException { $rval = $Instance->connect }; assert $rval, "Connect failed without error."; assertNoException { $Instance->disconnect }; }, }, # One-time setup function -- overrides the previous setup, but is # immediately discarded after executing once. { name => 'setup', func => sub { MyClass::prepNetwork(); }, }, # Now override the previous setup function with a new one that does # a connect() before each remaining test. { name => 'setup', test => sub { $Instance = new MyClass; $Instance->connect; }, } # Same thing for teardown/disconnect() { name => 'teardown', test => sub { $Instance->disconnect; undef $Instance; }, }, ... ); runTests( @testSuite ); Requirements: · Perl


Test::SimpleUnit Related Software