Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm glad you asked about Unit Testing, and not testing in general.</p> <p>Databases have many features that need to be tested. Some examples:</p> <ul> <li>Data Types/Size/Character sets (try inserting a swedish name, or long urls or numbers from the real worlds, and see if your column definitions are ok)</li> <li>Triggers</li> <li>Contraints (foreign keys, uniqueness...)</li> <li>Views (check that data is correctly included/excluded/transformed)</li> <li>Stored Procedures</li> <li>UDFs</li> <li>Permissions</li> <li>...</li> </ul> <p>This is useful not only when you change something in your database, but also when you upgrade your dbms, or change something in your settings.</p> <p>Generally, Integration Testing is done. This means that a Test Suite in a programming language like PHP or Java is created, and the tests issue some queries. But if something fails, or there are some exceptions, it's harder to understand the problem, for 2 reasons:</p> <ul> <li>The problem could be in your PHP code, or in PHP configuration, or in the network, or...</li> <li>The SQL statements are harder to read and modify, if they are embedded in another programming language.</li> </ul> <p>So, in my opinion, for complex databases you need to use a Unit Testing framework which is written in SQL (using stored procedures and tables). You have to choose it carefully, because that kind of tools is not widely used (and thus not widely tested). For example, if you use MySQL I know these tools:</p> <ul> <li>STK/Unit <a href="http://stk.wikidot.com/stk-unit" rel="nofollow">http://stk.wikidot.com/stk-unit</a></li> <li>utMySQL <a href="http://utmysql.sourceforge.net/" rel="nofollow">http://utmysql.sourceforge.net/</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload