A test coverage criterion allows to determine what situations of interest shall be tested in a particular application. By measuring the coverage the tester may also determine the completeness of the test. When part of the business logic of the program is embodied in SQL statements the conventional criteria (e.g. condition or decision coverage) fall short for deriving adequate test cases:
- The SQL query is a single statement in a program, therefore it is covered by a single execution.
- Although decision-based criteria may be used for clauses like WHERE, they are no adequate to handle the complexities of SQL (e.g. joins or null values).
The SQL Full Predicate Coverage criterion (FPC) allows to evaluate the coverage or complex queries and was first published in:
- J Tuya, MJ Suárez-Cabal, C de la Riva. Full predicate coverage for testing SQL database queries. Software Testing, Verification and Reliability, 20 (3) 237-288, September 2010.
FPC is based on the principles of Modified Condition Decision Coverage (MCDC) specifically taylored for SQL queries, which includes:
- Logical decisions in WERE and HAVING.
- Null values
- Joins between tables
- GROUP BY and aggregate functions
- CASE expressions
- Information from the database schema
Given a query, FPC is defined by a set of Coverage Rules, each representing a particular test situation. Each coverage rule is written in SQL and then executed against the test database: If it returns any row then the situation that represents is covered
The TdRules (formerly named SQLRules) toolset supports the generation and evaluation of FPC coverage rules (via a REST API Service or Web and Desktop client applications)