Blog do projektu Open Source JavaHotel

środa, 26 grudnia 2012

SQL unit testing, new version of BoaTester

Introduction
Plugin for BoaTester allowing  SQL unit testing has been created. Full description and samples are available here. Source code (test software and samples).
Motivation
Unlike popular programming languages like Java, C/C++ or Python there is no common framework for SQL unit testing. By "SQL unit testing" I mean testing of SQL server code, SP (stored procedures) and UDF (used defined function). The common testing method is to utilize the testing framework of the client side (for instance JUnit and running server code by means of JDBC).
It works of course but is not very convenient for me because it requires some additional coding not related directly to the server code.
So I extended a BoaTester framework to run a simple test scenario without additional coding. It allows running test scenario like.

  1. Create (or replace) a table (tables).
  2. Insert some data into the tables (tables).
  3. Deploy some server code (if not loaded independently)
  4. Launch SP or UDF 
  5. Check the result
  6. ... again
The test framework is pyunit and connection method is pyodbc .
Some features and problems
  • It is not easy to test OUT parameters of SP (stored procedure). The problem is described here in more detail.
  • It is possible to test also against sql exception expected. For instance - fail the test if SP does not throw an exception expected. So it is possible to test SP also for some error condition.
  • Marker parameters are implemented.
  • The common problem while developing server code is related to the different SQL dialects. SQLTesters allows to modify some SQL statements according to database under test. More info.
  • It is possible also to create more complicated test case scenario (by means of Python). More info.

Brak komentarzy:

Publikowanie komentarza