Samson Monaco Tutankhamen

NAME

Test::Tech - adds skip_tests and test data structures capabilities to the "Test" module

SYNOPSIS

 use Test::Tech

 @args    = tech_config( @args );

 $success = plan(@args);

 $test_ok = ok(\@actual_results, \@expected_results, $diagnostic, $test_name);
 $test_ok = skip($skip_test, \@actual_results,  \@expected_results, $diagnostic, $test_name);

 $test_ok = ok($actual_results, $expected_results, $diagnostic, $test_name);
 $test_ok = skip($skip_test, $actual_results,  $expected_results, $diagnostic, $test_name);

 $state = skip_tests( $on_off );
 $state = skip_tests( );

 $string = stringify( $var );

DESCRIPTION The "Test::Tech" module extends the capabilities of the "Test" module.

The design is simple. The "Test::Tech" module loads the "Test" module without exporting any "Test" subroutines into the "Test::Tech" namespace. There is a "Test::Tech" cover subroutine with the same name for each "Test" module subroutine. Each "Test::Tech" cover subroutine will call the &Test::$subroutine before or after it adds any additional capabilities. The "Test::Tech" module is a drop-in for the "Test" module.

The "Test::Tester" module extends the capabilities of the "Test" module as follows:

  • Compare almost any data structure by passing variables through Data::Dumper before making the comparision

  • Method to skip the rest of the tests upon a critical failure

  • Method to generate demos that appear as an interactive session using the methods under test

The Test::Tech module is an integral part of the US DOD SDT2167A bundle of modules. The dependency of the program modules in the US DOD STD2167A bundle is as follows:

 File::Package
   File::SmartNL Test::STD::Scrub
     Test::Tech
        DataPort::FileType::FormDB DataPort::DataFile Test::STD::STDutil
            Test::STDmaker ExtUtils::SVDmaker

plan subroutine

 $success = plan(@args);

The plan subroutine is a cover method for &Test::plan. The @args are passed unchanged to &Test::plan. All arguments are options. Valid options are as follows:

tests

The number of tests. For example

 tests => 14,
todo

An array of test that will fail. For example

 todo => [3,4]
onfail

A subroutine that the Test module will execute on a failure. For example,

 onfail => sub { warn "CALL 911!" } 

ok subroutine

 $test_ok = ok(\@actual_results, \@expected_results, $test_name);
 $test_ok = ok($actual_results, $expected_results, $test_name);

The test method is a cover function for the &Test::ok subroutine that extends the &Test::ok routine as follows:

  • Prints out the $test_name to provide an English identification of the test.

  • The ok subroutine passes the arrays from an array reference @actual_results and @expectet_results through &Data::Dumper::Dumper. The test method then uses &Test::ok to compare the text results from &Data::Dumper::Dumper.

  • The ok subroutine method passes variables that are not a reference directly to &Test::ok unchanged.

  • Responses to a flag set by the skip_tests subroutine subroutine and skips the test completely.

skip subroutine

 $test_ok = skip(\@actual_results, \@expected_results, $test_name);
 $test_ok = skip($actual_results, $expected_results, $test_name);

The skip subroutine is a cover function for the &Test::skip subroutine that extends the &Test::skip the same as the ok subroutine subroutine extends the &Test::ok subroutine.

skip_tests method

 $state = skip_tests( $on_off );
 $state = skip_tests( );

The skip_tests subroutine sets a flag that causes the ok and the skip methods to skip testing.

stringify subroutine

 $string = stringify( $var );

The stringify subroutine will stringify $var using the "Data::Dumper" module only if $var is a reference; otherwise, it leaves it unchanged.

For numeric arrays, "Data::Dumper" module will not stringify them the same for all Perls. The below Perl code will produce different results for different Perls

 $probe = 3;
 $actual = Dumper([0+$probe]);

For Perl v5.6.1 MSWin32-x86-multi-thread, ActiveState build 631, binary, the results will be '[\'3\']' while for Perl version 5.008 for solaris the results will be '[3]'.

This module will automatically, when loaded, probe the site Perl and will this statement and enter the results as 'string' or 'number' in the Internal_Number configuration variable.

tech_config subroutine

 $old_value = tech_config( $dot_index, $new_value );

The tech_config subroutine reads and writes the below configuration variables

 dot index              contents 
 --------------------   --------------
 Dumper.Terse          \$Data::Dumper::Terse
 Dumper.Indent         \$Data::Indent
 Dumper.Purity         \$Data::Purity
 Dumper.Pad            \$Data::Pad
 Dumper.Varname        \$Data::Varname
 Dumper.Useqq          \$Data::Useqq
 Dumper.Freezer        \$Data::Freezer
 Dumper.Toaster        \$Data::Toaster
 Dumper.Deepcopy       \$Data::Deepcopy
 Dumper.Quotekeys      \$Data::Quotekeys
 Dumper.Maxdepth       \$Data::Maxdepth
 Test.ntest            \$Test::ntest
 Test.TESTOUT          \$Test::TESTOUT
 Test.TestLevel        \$Test::TestLevel
 Test.ONFAIL           \$Test::ONFAIL
 Test.todo             \%Test::todo
 Test.history          \%Test::history
 Test.planned          \$Test::planned
 Test.FAILDETAIL       \@Test::FAILDETAIL
 Test.Program_Lines    \%Test::Program_Lines
 Test.TESTERR          \$Test::TESTERR
 Skip_Tests            # boolean
 Internal_Number       # 'string' or 'number'

The tech_config subroutine always returns the $old_value of $dot_index and only writes the contents if $new_value is defined.

The 'SCALAR' and 'ARRAY' references are transparent. The tech_config subroutine, when it senses that the $dot_index is for a 'SCALAR' and 'ARRAY' reference, will read or write the contents instead of the reference.

The The tech_config subroutine will read 'HASH" references but will never change them.

The variables for the top level 'Dumper' $dot_index are established by "Data::Dumper" module; for the top level 'Test', the "Test" module.

NOTES

AUTHOR

The holder of the copyright and maintainer is

<support@SoftwareDiamonds.com>

Copyrighted (c) 2002 Software Diamonds

All Rights Reserved

BINDING REQUIREMENTS NOTICE

Binding requirements are indexed with the pharse 'shall[dd]' where dd is an unique number for each header section. This conforms to standard federal government practices, US DOD 490A 3.2.3.6. In accordance with the License, Software Diamonds is not liable for any requirement, binding or otherwise.

LICENSE

Software Diamonds permits the redistribution and use in source and binary forms, with or without modification, provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

SOFTWARE DIAMONDS, http::www.softwarediamonds.com, PROVIDES THIS SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWARE DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING USE OF THIS SOFTWARE, EVEN IF ADVISED OF NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE POSSIBILITY OF SUCH DAMAGE.

SEE ALSO

Test Test::TestUtil