Wetware::Test::Suite - Basic Test::Class methods
use Wetware::Test::Suite; use base q{Wetware::Test::Suite};
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.
This will compare that the object_under_test() returned an object that isa_ok() for the class_under_test
This defines which class is actually under test.
Thus subclasses override this, and put in their class.
This is the Test(setup) method - and it calls class_under_test(). to get the class to construct.
class_under_test()
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.
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.
Deletes the object under test.
Test::Class
Test::More
Test::Differences - great eq_or_diff_text() method!
Test::Exception - because some things NEED to throw exceptions.
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.
"drieux", <"drieux [AT] at wetware.com">
<"drieux [AT] at wetware.com">
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.
To install Wetware::Test, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wetware::Test
CPAN shell
perl -MCPAN -e shell install Wetware::Test
For more information on module installation, please visit the detailed CPAN module installation guide.