Database Testing

Why test the database?

The database persists data that your application (and organization) depends on. The data thus persisted is most often of mission-critical nature and a key asset for the organization. Also, many of today's data-enabled applications implement a fair amount of their functionality and business logic in the database itself. For an enterprise class application, the data in the database would be accessed and updated (insert/modify/delete) simultaneously by a large number of users (think thousands to millions depending on the scale of your application's usage).

The above statements highlight a few areas where database testing is needed. One, to validate the quality of data being persisted. Two, if we plan to test the application code, it is imperative that we also test the code in the database which implements the business functionality and three, we should plan for non-functional database testing to support the usage of the database in a real-world deployment scenario.

Let us briefly look at the above mentioned database test areas.

1. Data quality testing

Testing the quality of the data may be approached in three ways - data validity testing, data integrity testing and data format testing.

a) Data validity testing - is done to verify the validity of the data that is stored in the database. When data is entered via the front end application, check if the data is correctly updated in the back-end database. Apart from the positive checks, look for other behavior such as data truncation, verify how null/empty field values are handled, verify how special characters or code snippets are handled in the database. Check that the right columns in the right tables are being updated. Data validity testing normally involves use of SQL queries to validate the data.

b) Data integrity testing - involves testing referential integrity and application of constraints (foreign/primary key). When a data field is subject to modification (insert, update or delete), the database should be verified for appropriate changes to related entities such as primary key/foreign key relationships and that referential integrity of the data is maintained

c) Data format testing - involves verifying the size and type of fields that store data in the database with those that accept data in the application. This can help identify mismatches between the type or size of data that is accepted by the front-end vs what the database can store. Example: the application may accept text data but try to store in a numeric or date field in the database or else the application may accept data of greater length than the max length for the corresponding field in the database. This may not throw errors during routine application usage but may store incorrect or erroneous data in the database which could have repercussions elsewhere or at a later stage
   
2. Database code testing - involves testing the code in the database which implements business logic and functionality. Examples of such code include, stored procedures, views (read-only/updateable) and event driven items such as triggers. Each stored procedure is tested distinctly for its functionality. When a stored procedure implements multiple functions, each function is tested separately. Stored procedure testing would look at testing the arguments that are passed to the stored procedure in terms of the number, type and order of arguments plus the return value. Both positive and negative tests can be devised to test stored procedures. Views both read only and updateable are tested either as stored queries that dynamically retrieve values from the database and/or allow updates to the database. In case where updates are allowed, data validity and integrity testing is done. Event driven items are tested by verifying the events that could trigger actions and the actions themselves for functional correctness

3. Non-functional database testing

In most real-world mission critical deployments, to ensure database scalability, security, availability and recover-ability with minimal/no-loss of data, it is important to test the following non-functional areas

a) Database performance testing (load/stress/longevity/scalability)
b) Database security testing
c) Database replication testing
d) Database fail-over testing
e) Database recovery testing

This sums up in brief, the subject of database testing.

Scrum And Quality Engineering: What Testers Must Bring To Agile Teams

Scrum does not automatically create quality. Quality emerges when the Scrum team uses the framework to create fast feedback, shared ownership, clear risk decisions, and releasable increments.

Scrum is intentionally lightweight. It defines roles, events, artifacts, and commitments, but it does not prescribe a complete engineering process. That is both its strength and its risk. A team can follow Scrum ceremonies and still have weak quality practices.

Where Quality Fits In Scrum

Quality should be visible in product backlog refinement, sprint planning, daily collaboration, review, retrospective, and the definition of done. If testing appears only at the end of the sprint, the team has recreated a phase-gate model inside an Agile wrapper.

Testers bring value by helping the team clarify acceptance conditions, identify risks, define examples, challenge assumptions, and decide what evidence is needed for each backlog item.

The Definition Of Done Is A Quality Contract

The definition of done is one of Scrum's most important quality mechanisms. It should make quality expectations explicit. Depending on the product, that may include code review, automated tests, exploratory testing, accessibility checks, performance considerations, security review, documentation updates, observability, and deployment readiness.

If the definition of done says only that development is complete, it is not a real definition of done. It is a handoff point.

What Testers Should Bring To Scrum Teams

  • Risk analysis during refinement and planning.
  • Concrete examples that clarify expected and unexpected behavior.
  • Exploratory testing around ambiguity, integration, usability, and workflow risk.
  • Automation strategy at the right level of the test pyramid.
  • Fast feedback on partial implementations, not only completed stories.
  • Clear communication of residual risk before review and release.

Common Scrum Quality Problems

  • Stories are sliced by implementation convenience rather than user value.
  • Testing is squeezed into the final days of the sprint.
  • Automation is deferred until "later" and later never comes.
  • Definition of done is weak or inconsistently applied.
  • Retrospectives discuss symptoms but do not improve engineering practices.

Scrum creates opportunities for quality, not guarantees. A strong quality engineer helps the Scrum team use those opportunities to build better feedback loops, stronger ownership, and more trustworthy increments.