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 to a MySQL server, just run the install script from the mytap directory:
This assumes local server access or user and host credentials in ~/.my.cnf.
The installer will create a database called
tap with 2 tables, import the
base package and any version specific patches. When installation has completed,
the test suite will run automatically. Any errors at this point should be
raised as issues because it will likely indicate a change in the MySQL
information_schema or a bug in a MySQL release against which myTAP has not
For installations on remote servers, non-standard port numbers, or where client credentials are not stored, provide the appropriate short or long-form switches for the required parameters. e.g.
# ./install.sh --port 3310 # ./install.sh --user root --password rootpassword 2>/dev/null # ./install.sh -h 127.0.0.1 -P 3310 --u root --p rootpassword 2>/dev/null
The installer can run a subset of the tests with the --filter option
# ./install.sh --filter table
or, to skip the tests entirely
# ./install.sh --no-tests
Finally, it is also possible to run the installer in test-only mode (useful for developers) with
# ./install.sh --no-install
Short-form versions of all of these switches exist, for full details
# ./install.sh --help
###Amazon Aurora MyTAP may be used on Amazon Aurora but the installation script will generate some errors because Aurora does not permit the use of the SUPER privilege which is necessary to set the MySQL Global variable log_bin_trust_function_creators. It is possibile to work around this issue by creating a new parameter group for your Aurora instance and setting this variable in Edit Parameters within the AWS console. Full instructions on a workaround can be found in this answer on Stack Overflow.
This same issue will cause some errors in running the current version of the test scripts for VIEWS and PRIVILEGS which rely on SUPER privilege to define suitable test data.
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.