Do you have tests for your database manipulation code?
We know the answer. In our research, we studied how database manipulation code is tested in open-source projects. We developed an Eclipse plugin that performs a static analysis based on the Eclipse Java AST to identify the code involved in database communication, and we analyzed hundreds of open-source projects. We were curious about how open-source projects test database access code and found that the database is poorly tested. About 46% of the projects with executable tests did not cover half of their database access methods, and 33% of the projects did not cover the database code at all. Developers face many challenges. Do integration or unit tests need to be written? Should mocks be implemented or an in-memory database be used? How should a database be reset or repopulated between tests? These are only a few examples.
In this talk, we briefly introduce the analysis technique based on our Eclipse plugin and show examples of interesting prevalent problems in testing database manipulation code.