Test::GlassBox::Heavy

Non-invasive testing of subroutines within Perl programs
Download

Test::GlassBox::Heavy Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Oliver Gorwits
  • Publisher web site:
  • http://search.cpan.org/~oliver/

Test::GlassBox::Heavy Tags


Test::GlassBox::Heavy Description

Non-invasive testing of subroutines within Perl programs If you have a Perl program to test, one approach is to run the program with various command line options and environment settings and observe the output. This might be called black box testing because you're treating the program as an opaque blob. Some time later you need to refactor a part of the program, so you want to move on and begin unit testing the subroutines in the program. This is tricky to do without accidentally running the program itself. At this point you're glass box testing because you can inspect the internals of the program, although you're not actually changing them. Test::GlassBox::Heavy is a Perl module that takes a rather heavyweight approach to the above using some of Perl's deep magic, such as the Devel:: and B:: namespace modules. It stops the Perl program from being run, but allows you to call any subroutine defined in the program. Essentially it turns the program into a package. You'll need to set-up any environment the subroutines may need, such as global lexical variables, and also be aware that side effects from the subroutines will still occur (e.g. database updates).SYNOPSIS use Test::GlassBox::Heavy qw(load_subs); # set up any globals to match those in your Perl program my $global = 'foo'; load_subs( $perl_program_file ); # subs from $perl_program_file are now available for calling directly # OR load_subs( $perl_program_file, $namespace ); # subs from $perl_program_file are now available for calling in $namespacePURPOSEYou have a (possibly ancient) Perl program for which you'd like to write some unit tests. The program code cannot be modified to accommodate this, and you want to test subroutines but not actually run the program. This module takes away the pain of setting up an environment for this, so you can run the subroutines in (relative) safety. Requirements: · Perl


Test::GlassBox::Heavy Related Software