Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stored procedures and unit testing

Tags:

Does anybody know of a framework (or methodology) to unit test stored procedures just using SQL and be able to produce a reasonable report as to what has passed and what has failed (something similar to CPPUnit)?

like image 205
Ed Heal Avatar asked Oct 05 '11 16:10

Ed Heal


People also ask

What is stored procedure testing?

The Stored Procedure Test tool (SP Test tool) makes the testing of stored procedures easier. It enables you to test various input values for a stored procedure, see the results, and optionally create test scripts without having to write COBOL code to invoke the stored procedure.

What is unit testing in SQL?

SQL unit testing is a testing method which allows us to test the smallest, atomic programmable part of a database object. SQL unit testing plays a key role in the modern database development cycle because it allows us to test individual parts of the database objects work as expected.

What is the procedure for unit testing?

A unit test typically comprises of three stages: plan, cases and scripting and the unit test itself. In the first step, the unit test is prepared and reviewed. The next step is for the test cases and scripts to be made, then the code is tested.


2 Answers

MyTAP will probably be what you are looking for, you can find it in Github

it describes itself as: '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.'

MyTAP is now hosted at [https://github.com/hepabolu/mytap][1]

like image 150
Kevin Burton Avatar answered Sep 27 '22 22:09

Kevin Burton


Maybe you want to try STK/Unit, which is written in pure SQL and supports the ideas of Test Case and Test Suite. Also, supports expectations. http://stk.wikidot.com/stk-unit

like image 36
Federico Razzoli Avatar answered Sep 27 '22 20:09

Federico Razzoli