MySQL Unit Testing Suite
Clone or download
animalcarpet Feature/aurora (#40)
* document AURORA workaround
Latest commit a5bb340 Sep 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Feature/aurora (#40) Sep 19, 2018
scripts Feature/travis ci (#35) Aug 19, 2018
tests Privileges attempt 2 (#38) Sep 1, 2018
.travis.install-mysql.sh Feature/travis ci (#35) Aug 19, 2018
.travis.yml Feature/travis ci (#35) Aug 19, 2018
Changes Releasing version 1.0 of MyTAP Jul 21, 2018
LICENSE Separate license file added with BSD-3 license and copyright noticed … Jun 18, 2017
README.md Feature/aurora (#40) Sep 19, 2018
install.sh Privileges attempt 2 (#38) Sep 1, 2018
mytap-charset.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-collation.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-column.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-constraint.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-engine.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-event.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-global-576.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-global.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-index.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-partition.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-privilege.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-role-8011.sql roles must reflect user_at_host changes Aug 18, 2018
mytap-role.sql Feature/travis ci (#35) Aug 19, 2018
mytap-routines.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-schemata.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-table-564.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-table-576.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-table-8011.sql moving function load out of mytap.sql necessitates setting default db Aug 2, 2018
mytap-table.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-timezone.sql Add timezone checks Jul 24, 2018
mytap-trigger.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap-user-576.sql version numbers sorted for point releases Jul 29, 2018
mytap-user.sql Feature/travis ci (#35) Aug 19, 2018
mytap-view.sql Privileges attempt 2 (#38) Sep 1, 2018
mytap.sql Privileges attempt 2 (#38) Sep 1, 2018
runsandboxtests.sh first attempt to run the tests against multiple sandboxed versions of… Jun 19, 2017

README.md

MySQL 5.5 MySQL 5.6 MySQL 5.7 MySQL 8.0 Build Status

MyTAP 1.0

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.

Installation

To install MyTAP to a MySQL server, just run the install script from the mytap directory:

# ./install.sh

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 been tested.

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.

https://stackoverflow.com/a/30874794/5870171

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!

Yeah, that's rather a lot of options to have to remember to get valid tap. I suggest that you install TAP::Parser::SourceHandler::MyTAP instead and just use its my_prove utility:

% my_prove -u root --database test test.sql

Using MyTAP

The purpose of MyTAP is to provide a wide range of testing utilities that output TAP. TAP, or the "Test Anything Protocol", is an emerging standard for representing the output from unit tests. It owes its success to its format as a simple text-based interface that allows for practical machine parsing and high legibility for humans. TAP started life as part of the test harness for Perl but now has implementations in C/C++, Python, PHP, JavaScript, Perl, PostgreSQL, and now MySQL.

More information on the use of MyTAP can be found in the documentation.

To Do

  • Port lot of other assertion functions from pgTAP.

Public Repository

The source code for MyTAP is available on GitHub. Please feel free to fork and contribute!

Authors

Credits

  • 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.