Testing database applications typically requires the generation of tests consisting of both program inputs and
database states. Recently, a testing technique called Dynamic Symbolic Execution (DSE) has been proposed
to reduce manual effort in test generation for software applications. However, applying DSE to generate tests
for database applications faces various technical challenges. For example, the database application under
test needs to physically connect to the associated database, which may not be available for various reasons.
The program inputs whose values are used to form the executed queries are not treated symbolically, posing
difficulties for generating valid database states or appropriate database states for achieving high coverage of
query-result-manipulation code. To address these challenges, in this article, we propose an approach called
SynDB that synthesizes new database interactions to replace the original ones from the database application
under test. In this way, we bridge various constraints within a database application: query-construction
constraints, query constraints, database schema constraints, and query-result-manipulation constraints.We
then apply a state-of-the-art DSE engine called Pex for .NET from Microsoft Research to generate both
program inputs and database states. The evaluation results show that tests generated by our approach can
achieve higher code coverage than existing test generation approaches for database applications