NAME
Persist::Test - Persist helper for testing drivers
SYNOPSIS
use Test::More;
use Persist::Test;
plane tests => count_sources;
while (my ($name, $source) = next_source) {
# create your tables and run your code
# don't bother cleaning up, this will be done for you
}
DESCRIPTION
This tool provides a standard set of tests for testing the standards compliance of Persist drivers and for testing user code against all installed database systems.
As far as the typical user need know the standards compliance testing happens automatically when make test
is called. However, If you are interested in writing a driver, then you'll just have to examine the guts of existing drivers as there is no documentation on how to use this system to test your code--it's pretty simple to hack.
TESTING USER CODE
If you use Persist and would like to make certain that you code will work against all configured drivers--as each driver may vary slightly, here is the plan: (1) write your code, (2) write each unit test using the shell given in the SYNOPSIS, (3) run your tests. Easy.
You don't even need to clean-up--assuming that all your work is done in tables you created during the test. Any table created during the test will be dropped when the test exits. There is always a chance this will fail, but if it does the system will complain to the user exactly what has happened and what appears to be required to fix it.
WARNING: At this time, the testing system is not yet able to cleanup after newly created sources. This is a feature we'd like to have, but it simply isn't feasible right now. Therefore, you must clean up any sources you create yourself--creating sources is itself would be a challenge since each driver manages sources differently and you can't (easily) tell which driver you are using. At this time, it is recommended that you don't mess with creating and deleting sources during tests, unless you do so by some other method than this test framework.
AUTHOR
Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>
COPYRIGHT AND LICENSE
Copyright (c) 2003, Andrew Sterling Hanenkamp
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Persist nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 THE
COPYRIGHT OWNER OR CONTRIBUTORS 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 NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.