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

NAME

Myco::Test::EntityTest - base class for Myco entity test classes

---these docs need expansion---

SYNOPSIS

 ### Set up an entity test class (don't do this by hand!  Use myco-mkentity!)
 ###

 package Myco::Foo::Test;

 use base qw(Test::Unit::TestCase Myco::Test::EntityTest);

 # This class tests features of:
 my $class = 'Myco::Foo';

 my %test_parameters =
  ###  Test Control Prameters ###
  (
   # A scalar attribute that can be used for testing... set to undef
   #    to disable related tests
   simple_accessor => 'fooattrib',

   # Default attribute values for use when constructing objects
   #    Needed for any 'required' attributes
   defaults =>
       {
        name => 'a value',
        # Use a coderef to auto-instantiate sub-objects for ref-type
        #   attributes
        type => sub {
                   my $test = shift;
                    my $foo = Myco::Foo->new(name => 'bar');
                    # Make sure sub-object gets removed after test
                    $test->destroy_upon_cleanup($foo);
                    $foo;
                },
      },
  );

 # Example test method
 sub test_bar {
     my $test = shift;
     $test->set_type_persistence(1);  # note that this test uses the db
     return if $test->should_skip;    # skip over this test if asked

     # Create entity object with any required attributes as specified
     # in %test_parameters{defaults}
     my $obj = $test->new_testable_entity;
     $obj->save;           # save to persistent storage, if you like

     # ...do something...
     $test->assert( __something__, "no can-do");

     # Use the following to have Entity objects auto-deleted after
     # test is run
     $test->destroy_upon_cleanup($obj);
 }


 ### Running tests
 ###

 $ cd $MYCO_DISTRIB/driver
 $ ./myco-testrun Myco::Foo::Test [-T]       # run tests
                                        # '-T' enables Tangram trace mode
 $ ./tkmyco-testrun Myco::Foo::Test          # run tests, GUI style

DESCRIPTION

Base class for all Myco entity test classes. An entity test class benefits in two ways:

  • It is tied into a Test::Unit::TestCase-based framework which takes care of database connection worries and various other concerns.

  • It inherits a collection of canned tests that will automatically get run along with any tests unique to a given entity.

LICENSE AND COPYRIGHT

Copyright (c) 2006 the myco project. All rights reserved. This software is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Charles Owens <owensc@enc.edu>

SEE ALSO

Myco::Entity, Myco::Test::Suite, myco-testrun, tkmyco-testrun, Test::Unit::TestCase