The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Wetware::Test::Suite - Basic Test::Class methods

SYNOPSIS

    use Wetware::Test::Suite;
        use base q{Wetware::Test::Suite};

DESCRIPTION

This module inherits from Wetware::Test::Class, so it will be useable within the Test::Class::Load approach.

This module provides the five common methods that are used over and over and over again in a Test::Class apporach to providing appropriate test coverage.

This makes creating the simple starter test case really simple

     sub test_new_method_name  : Test(1) {
       my $self = shift;
       my $class = $self->class_under_test();
       Test::More::can_ok($class, 'new_method_name');
       return $self;
     }

Which is a great wayt to make sure that one is not starting a new method that one has already inherited.

Methods

test_new()

This will compare that the object_under_test() returned an object that isa_ok() for the class_under_test

class_under_test()

This defines which class is actually under test.

Thus subclasses override this, and put in their class.

set_up( [ %params ] )

This is the Test(setup) method - and it calls class_under_test(). to get the class to construct.

It can take an optional hash of parameters to pass to the constructor.

It will return $self.

It will call new_object_under_test_for(%params) to create the test object.

new_object_under_test_for(%params)

Passes the %params to the class constructor, and sets the object under.

This can be used to construct a new object, and will replace the previous one.

Note - if your sub class starts doing interesting things with the constructor, and there are need for default params, then overriding this method will make that reasonably simple.

object_under_test()

Accessor to the object under test. This way one can do the other stock test format:

     sub test_new_method_name  : Test(1) {
       my $self = shift;
       my $object = $self->object_under_test();
       Test::More::can_ok($object, 'new_method_name');
    
       # ever more increasing testing of the object
       # ...
    
       return $self;
     }
        

in anticipation of actully using the one that was created by the set_up.

tear_down()

Deletes the object under test.

SEE ALSO

Test::Class

Test::More

Test::Differences - great eq_or_diff_text() method!

Test::Exception - because some things NEED to throw exceptions.

ACKNOWLEDGEMENTS

I want to thank Matisse Enzer for the introduction to building up Test::Class based testing.

I am still debating if we really gain anything with useing 'class_under_test()' to define the key into $self where we keep object_under_test.

AUTHOR

"drieux", <"drieux [AT] at wetware.com">

COPYRIGHT & LICENSE

Copyright 2009 "drieux", all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.