History
The beginning of this project is associated with log4db2. I was developing that project that seems a simple one: just log an event in Db2; however, many conditions arose and the project became very big and complex. As one of my High School teacher used to say "God, save me from simple questions: from the difficult one I save myself". Well, in this case, it was almost a simple question: How can I log a message in Db2?
Once log4db2 was big, I needed to test the different components and that became a very hard process. I used to to it manually, by executing individually many tests and that became impossible to deal with. However, as part of this process I have developed many techniques to automate things in Db2. Then I said, there should be something on the Internet that does that with Db2. The first thing to appear in the search results was a project from Philip Nelson in SourceForge called db2unit with some of the features I needed. But that project was just an intention, the project itself did not exist, just the main page of a website and that is it. Also, during that research, I found many projects for other RDBMS, but nothing for Db2.
I decided to develop db2unit by myself with the same structure of jUnit (I am a Java fan). The core of the project was developed in three days, and I had something that could work and test my log4db2 project. I called the project db2unit because this is the right name it should have, even if someone else had called a website with no project with the same name. At that moment, I had two Db2 projects, and both of them became very complex.
During the initial development, I wanted a cool logo, something related with Colombia, my country of origin. I wanted an animal in extinsion danger, to make it visible to the world; after looking at very different animals I chose the danta or tapir.
Days later, I wanted to make more visible this project, and I decided to write an article in DeveloperWorks. But for that, I needed a pair that check what I wrote, so I asked Helmut Tessarek (@tessus) to be my reviewer, and he gently was my pair in that article. Currently, the article is published at: https://www.ibm.com/developerworks/data/library/techarticle/dm-1501unittest-sql-db2/index.html
Once the project was running, I was contacted by Robert Mala (@dibdotdob), a Db2 specialist that wanted to include XML assertions in the code. He has helped me a lot in this, and he has provided many other features in the code.
Self testing
db2unit is a testing framework, and the framework itself is tested with this tool.
If you want to run the test, install the framework from the sources, execute the files: Tests_TEST_DB2UNIT_ASSERTIONS.sql
and Tests_TEST_DB2UNIT_EXECUTION.sql
against the database, and then just run the test suites:
CALL DB2UNIT.RUN_SUITE('TEST_DB2UNIT_EXECUTION')
CALL DB2UNIT.RUN_SUITE('TEST_DB2UNIT_ASSERTIONS')
For more information visit this page"
- https://github.com/angoca/db2unit/wiki/Install-from-sources#install--run-tests
Continuous Integration
The continuous integration of this framework works with Travis-CI. Each time a block of code is published, the whole project will be tested and the results can be seen in the right column of this text (if it is failing or passing.)
Also, you can see the output by looking the jobs at https://travis-ci.org/angoca/db2unit
This is a great feature to ensure that the db2unit code is self-tested and its results are ok. This integration with Travis-CI shows how this framework has been developed following the TDD (Test Driven Development) guidelines.
Projects using db2unit
There are not too many open source projects for Db2, and that is the reason this is a small list for the moment:
- The project itself db2unit
- log4db2
- db2-hash-routines - Forge https://github.com/tessus/db2-hash-routines
Db2 versions
This is the list of Db2 versions where the framework has been used / tested:
- Db2 10.5 FP 5 on RedHat 7.5
- Db2 10.5 FP 5 on Ubuntu 12.04
- Db2 10.5 FP 4 Cancun on Ubuntu 14.04
- Db2 10.5 FP 1 on Windows 7
- Db2 10.1 FP 2 on Ubuntu 12.04
- Db2 10.1 GA on Mac OS Mavericks
- Db2 9.7 FP 8 on AIX 7.3
- Db2 9.7 FP 5 on Ubuntu 12.04
Media
In this section, all Internet resources different to this wiki are listed.
- Initial description of this framework - http://angocadb2.blogspot.fr/2014/02/unit-testing-framework-for-db2.html
- Article in DeveloperWorks - https://www.ibm.com/developerworks/data/library/techarticle/dm-1501unittest-sql-db2/index.html
Similar projects
Multidatabase tests
- http://www.dbunit.org/ - http://dbunit.sourceforge.net/ - Database generic tests
- http://dbfit.github.io/dbfit/ - dbFit (FitNesse) for acceptance tests.
- http://www.dbtestdriven.com/
- http://jdbdt.org/
- https://github.com/six42/jdbcslim
- https://github.com/lordofthejars/nosql-unit (MongoDB, Cassandra, Neo4j, Redis, HBase, CouchDB, Infinispan, ElasticSearch
- https://github.com/NDbUnit/NDbUnit
PL/SQL frameworks:
- http://code.google.com/p/pluto-test-framework/
- http://utplsql.sourceforge.net/
- (No longer available) http://help.apollopro.com/pl_unit.htm
- https://github.com/sodonnel/plsql-unit-test
- http://www.quest.com/toad-development-suite-for-oracle/code-tester-for-oracle.aspx
- https://github.com/rsim/ruby-plsql-spec
- http://plunit.com/
- https://docs.oracle.com/cd/E15846_01/doc.21/e15222/unit_testing.htm
- https://support.quest.com/code-tester-for-oracle, https://www.toadworld.com/products/toad-for-oracle/w/codetester
Maven plugins for PL/SQL:
- https://code.google.com/p/maven-utplsql-plugin/ - Maven plugin for PL/SQL
- http://code.google.com/p/plsqlmaven/ - Maven plugin for PL/SQL
Test framework for Ms SQL Server
- http://tsqlt.org/ - SQL Server
- http://sourceforge.net/projects/tsqlunit/ - SQL Server
- http://www.red-gate.com/products/sql-development/sql-test/ - SQL Server
- https://www.apexsql.com/sql_tools_unit_test.aspx
- https://github.com/chrisoldwood/SS-Unit - SQL Server
- https://tst.codeplex.com/ - SQL Server
- https://msdn.microsoft.com/en-us/library/jj851200(VS.103).aspx - SQL Server
- http://blogs.msdn.com/b/ssdt/archive/2012/12/07/getting-started-with-sql-server-database-unit-testing-in-ssdt.aspx
Test frameworks for others DBs:
- http://sqlunit.sourceforge.net/ - via JDBC for different RDBMS
- http://pgtap.org/ - Postgres
- http://utmysql.sourceforge.net/ - MySQL / MariaDB
- http://testanything.org/
- http://en.wikipedia.org/wiki/Test_Anything_Protocol
List of unit test frameworks:
- http://everything.explained.today/List_of_unit_testing_frameworks/
- http://wiki.c2.com/?TestingFramework
- https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks
More useful information:
- https://www.simple-talk.com/sql/database-delivery/database-lifecycle-management-for-etl-systems/ - This is an article that promotes the use of xUnit projects for databases when writing ETLs.
- http://sqlmag.com/t-sql/unit-test-your-stored-procedures
- https://maven.apache.org/surefire/maven-surefire-report-plugin/ - Maven tests report