MyTAP is a unit testing framework for MySQL 5.x written using fuctions and procedures. It includes a collection of TAP-emitting assertion functions, as well as the ability to integrate with other TAP-emitting test frameworks.
To install MyTAP into a MySQL database, just run
mysql -u root < mytap.sql
This will install all of the assertion functions, as well as a cache table, into a database named "tap".
MyTAP Test Scripts
Here's an example of how to write a MyTAP test script:
-- Start a transaction. BEGIN; -- Plan the tests. SELECT tap.plan(1); -- Run the tests. SELECT tap.pass( 'My test passed, w00t!' ); -- Finish the tests and clean up. CALL tap.finish(); ROLLBACK;
Note how the TAP test functions are reference from another database so as to keep them separate from your application database.
Now you're ready to run your test script!
% mysql -u root --disable-pager --batch --raw --skip-column-names --unbuffered --database test --execute 'source test.sql' 1..1 ok 1 - My test passed, w00t!
% my_prove -u root --database test test.sql
More information on the use of MyTAP can be found in the documentation.
- Port lot of other assertion functions from pgTAP.
The source code for MyTAP is available on GitHub. Please feel free to fork and contribute!
- Michael Schwern and chromatic for Test::More.
- Adrian Howard for Test::Exception.
Copyright and License
Copyright (c) 2010 David E. Wheeler, Helma van der Linden. Some rights reserved.
The full license is available in a separate LICENSE file.