Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to implement Test Driven Development in SQL?

I am not a Db guy. I am just curious if there is a possibility to write asserts in Sql so that you can write unit tests for your scripts, for your sprocs etc. and then even implement a Test Driven Development approach to your sessions?

thanks!

like image 834
pencilCake Avatar asked Dec 15 '10 13:12

pencilCake


1 Answers

You can do that actually, not directly from SQL throught, but the language you do your application.

Of cause you SQL must be incapsulated in DAL (Data Access Layer) and all data got by Repositories (or other data access classes). You can do unit testing of those classes, that would be running SQL scripts at the end. So, basically you will test your SQL code.

It is simplier to me, than trying to write such tests in SQL. :)

Sometime ago I had thought on that: http://www.beletsky.net/2010/11/testing-database-and-test-database.html

like image 177
Alexander Beletsky Avatar answered Sep 29 '22 13:09

Alexander Beletsky