a primer on testing database driven applications
play

A Primer on Testing Database-Driven Applications Gregory M. - PowerPoint PPT Presentation

A Primer on Testing Database-Driven Applications Gregory M. Kapfhammer Department of Computer Science Allegheny College 3rd Biennial Intramural Faculty Conference May 18 - 19, 2004 D atabase dr I ven A pplication T esting t O ol M odule S ,


  1. A Primer on Testing Database-Driven Applications Gregory M. Kapfhammer Department of Computer Science Allegheny College 3rd Biennial Intramural Faculty Conference May 18 - 19, 2004 D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 1/23

  2. Outline Introduction and Motivation Testing Challenges Database-Driven Applications A Unified Representation Test Adequacy Criteria Test Suite Execution Test Coverage Monitoring Conclusions and Resources D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 2/23

  3. Invocation Thus spake the master, “ Any program, no matter how small, contains bugs. ” The novice did not believe the master’s words. “ What if the program were so small that it performed a single function? ” The master thoughtfully responded, “ Such a program would have no meaning. But, if such a one existed, the operating system would fail eventually, producing a bug. ” D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 3/23

  4. Invocation But the novice was not satisfied. “ What if the operating system did not fail? ” The master responded, “ There is no operating system that does not fail. But if such a one existed, the hardware would fail eventually, producing a bug. ” The novice still was not satisfied. “ What if the hardware did not fail? ” D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 4/23

  5. Invocation The master gave a great sigh. “ There is no hardware that does not fail. But if such a one existed, the user would want the program to do something different, and this too is a bug. ” A program without bugs would be an absurdity, a nonesuch. If there were a program without any bugs then the world would cease to exist . Geoffrey James The Zen of Programming (Adaptation) D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 5/23

  6. Life of a Program: Compilation P P Compiler Byte Code Source Code The programming language compiler produces a representation of a program that can be executed D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 6/23

  7. Life of a Program: Execution P Input Output a 5 print ... exit Final Result: 45 Byte Code Virtual Machine The virtual machine executes the program’s byte codes D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 7/23

  8. Testing Challenges I shall not deny that the construction of these testing programs has been a major intellectual effort: to convince oneself that one has not overlooked “a relevant state” and to convince oneself that the testing programs generate them all is no simple matter. The encouraging thing is that (as far as we know!) it could be done. Edsger W. Dijkstra, 1968 D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 8/23

  9. Where Bugs Live P Input Output a 5 print ... exit Final Result: 45 Byte Code Virtual Machine Database Operating System File System Execution Environment D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 9/23

  10. Motivation The Risks Digest, Volume 22, Issue 64, 2003 Jeppesen reports airspace boundary problems About 350 airspace boundaries contained in Jeppesen NavData are incorrect, the FAA has warned. The error occurred at Jeppesen after a software upgrade when information was pulled from a database containing 20,000 airspace boundaries worldwide for the March NavData update, which takes effect March 20. D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 10/23

  11. More Testing Challenges Should consider the environment in which software applications execute Must test a program and its interaction with a database Database-driven application’s state space is well-structured, but infinite (Chays et al.) Need to show program does not violate database integrity, where integrity = consistency + validity (Motro) Must locate program and database coupling points that vary in granularity D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 11/23

  12. Database-Driven Applications P R 1 A C D B m i R 2 D k E F G H R 3 m j K I J L D l Program P interacts with two relational databases D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 12/23

  13. Database Interaction Levels D 1 P D n Database Level A program can interact with a database at different levels of granularity D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 13/23

  14. Database Interaction Levels D 1 UserInfo P user_name card_number pin_number acct_lock D n 1 32142 Brian Zorman 0 2 41601 Robert Roos 0 3 45322 Marcus Bittman 0 0 4 56471 Geoffrey Arnold Relation Level D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 13/23

  15. Database Interaction Levels D 1 UserInfo P user_name card_number pin_number acct_lock D 1 n 32142 Brian Zorman 0 2 41601 Robert Roos 0 3 45322 Marcus Bittman 0 0 4 56471 Geoffrey Arnold Record Level D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 13/23

  16. Database Interaction Levels D 1 UserInfo P user_name card_number pin_number acct_lock D n 1 32142 Brian Zorman 0 2 41601 Robert Roos 0 3 45322 Marcus Bittman 0 0 4 Geoffrey Arnold 56471 Attribute Level D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 13/23

  17. Database Interaction Levels D 1 UserInfo P user_name card_number pin_number acct_lock D 1 n 32142 Brian Zorman 0 2 41601 Robert Roos 0 3 45322 Marcus Bittman 0 0 4 56471 Geoffrey Arnold Attribute Value Level D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 13/23

  18. Database Interaction Points delete from r select A 1 , A 2 , . . . , A q where Q from r 1 , r 2 , . . . , r m where Q update r insert into r ( A 1 , A 2 , . . . , A q ) set A l = F ( A l ) values ( v 1 , v 2 , . . . , v q ) where Q D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 14/23

  19. Refined Database-Driven Application * from R select 1 where A < ( avg(G) select from ) R 2 P R 1 A B C D m i R 2 D k F E G H R 3 m j I J K L D l R 3 update set J = 500 L < 1000 where D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 15/23

  20. Data Flow Information Interaction point: ‘‘UPDATE UserInfo SET acct lock=1 WHERE card number=’’ + card number + ‘‘;’’; Database Level: define(BankDB) Attribute Level: define(acct_lock) and use(card_number) Data flow information varies with respect to the granularity of the database interaction D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 16/23

  21. Test Adequacy Criteria Database interaction association (DIA) involves the all−attribute−value−DUs def and use of a database entity all−record−DUs all−attribute−DUs DIAs can be located in the DICFG with data flow analysis all-database-DUs requires all−relation−DUs all−database−DUs tests to exercise all DIAs for all of the accessed databases D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 17/23

  22. Generating Test Requirements Relational Schema Database Seeder Database System Under Test Test Adequacy Criterion (C) (P) Test Case Specification Test Requirements D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 18/23

  23. Tracking Covered DIGs and DIAs P DIG r DB 1 m i DIG Coverage Table 2 DIG # DEF USE TEST COV? 1 { ... } { ... } { ... } DIG s q { ... } 1 { ... } { ... } m j 2 DIA coverage can be tracked by recording which DIGs within a DICFG were executed during testing D atabase dr I ven A pplication T esting t O ol M odule S , Allegheny Faculty Conference, May 18, 2004 – p. 19/23

  24. Types of Test Suites ∆ 0 m T 1 ∆ 0 ∆ 0 1 ∆ 1 m 1 m 1 T T 1 1 ∆ ε−1 ∆ 1 ∆ 1 m T ε ε ∆ e−1 ∆ e−1 ∆ ε m e T m e T e ∆ e e ∆ ∆ m T e e e e ∆ e Independent Non-restricted Partially Independent – p. 20/23

  25. Calculating Adequacy m i T f m j m i m j Test Requirements Test Requirements DIA DIA COV? COV? <def(e5), use(e5)> <def(e1), use(e1)> <def(e6), use(e6)> <def(e2), use(e2)> <def(e7), use(e7)> <def(e3), use(e3)> <def(e8), use(e8)> <def(e4), use(e4)> <def(e9), use(e9)> <def(e10), use(e10)> cov ( m i ) = 2 cov ( m j ) = 4 cov ( T f ) = 6 4 6 10 – p. 21/23

Recommend


More recommend