Database communication has a distinctive role in the codebase. We have to deal with libraries dedicated to specific databases, and we often use query languages such as SQL. It is tempting to avoid touching such code, and when it comes to testing, we face many challenges. To mention only a few examples: Will we mock or use an in-memory database? Do we need to write an integration test or a unit test? How do we know which code is responsible for database communication?
In a research project, we studied how database access code is tested in open-source projects. We used an Eclipse plugin that performs a static analysis based on the Eclipse Java AST to identify which part of the code is involved in database communication. In particular, it identifies the exact locations in Java classes where SQL statements are sent to the database, and it extracts the complete queries. We were curious about how different projects test database access code, and we found the developers faced interesting challenges. In this talk, we will briefly introduce the analysis technique we used and show examples of the most prevalent problems in testing database communication.
Testing practices of database communication in open-source projects
Objective of the presentation:
Learn different approaches and the difficulties of testing database communication.
Demonstrate an example of a static tool built on Eclipse technologies to analyse database access code in Java programs.
Attendee pre-requisites - If none, enter "N/A":
N/A