software testing finding software faults n.
Skip this Video
Loading SlideShow in 5 Seconds..
Software Testing: Finding Software Faults PowerPoint Presentation
Download Presentation
Software Testing: Finding Software Faults

Software Testing: Finding Software Faults

193 Vues Download Presentation
Télécharger la présentation

Software Testing: Finding Software Faults

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Software Testing: Finding Software Faults

  2. Topics covered • Introduction to testing • Sources of errors • Why do we need testing ? • Verification and validation planning • Software inspections. • Static and dynamic verification. • Automated static analysis

  3. Failures in Production Software • NASA’s Mars lander, September 1999, crashed due to a units integration fault—over $50 million US ! • Huge losses due to web application failures • Financial services : $6.5 million per hour • Credit card sales applications : $2.4 million per hour • In Dec 2006,’s BOGO offer turned into a double discount • NIST report, “The Economic Impacts of Inadequate Infrastructure for Software Testing” (2002) • Inadequate Software Testing costs the US alone between $22 and $59 billion annually • Better approaches could cut this amount in half • Stronger testing could solve most of these problems Thanks to Dr. Sreedevi Sampath

  4. Airbus 319 Safety Critical Software Control Loss of autopilot Loss of most flight deck lighting and intercom Loss of both the commander’s and the co‑pilot’s primary flight and navigation displays

  5. Northeast Blackout of 2003 508 generating units and 256 power plants shut down Affected 10 million people in Ontario, Canada Affected 40 million people in 8 US states Financial losses of $6 Billion USD The alarm system in the energy management system failed due to a software error and operators were not informed of the power overload in the system

  6. Testing Results v — Vasileios Papadimitriou. Masters thesis, Automating Bypass Testing for Web Applications, GMU 2006

  7. Software is a Skin that Surrounds Our Civilization

  8. Testing in the 21st Century • We are going through a time of change • Software defines behavior • network routers, finance, switching networks, other infrastructure • Today’s software market : • is much bigger • is more competitive • has more users • Agile processes put increased pressure on testers • Embedded Control Applications • airplanes, air traffic control • spaceships • watches • ovens • remote controllers Industry is going through a revolution in what testing means to the success of software products • PDAs • memory seats • DVD players • garage door openers • cell phones

  9. Testing in the 21st Century • More safety critical, real-time software • Enterprise applications means bigger programs, more users • Embedded software is ubiquitous … check your pockets • Paradoxically, free software increases our expectations ! • Security is now all about software faults • Secure software is reliable software • The web offers a new deployment platform • Very competitive and very available to more users • Web apps are distributed • Web apps must be highly reliable

  10. SE is concerned with BIG programs complexity is an issue software evolves development must be efficient you’re doing it together software must effectively support users involves different disciplines SE is a balancing act Central themes

  11. How do we get here ? operating system growth size in millions of lines of code From Frans Kaashoek and Jerome Saltzer, Topics in the Engineering of Computer Systems.

  12. Where do we get our faults from: operating systems ?

  13. Global distribution of effort Integration 10% engineering 10% coding 20% design 15% specification 10% testing 45% Do we follow a Methodology when building software ?

  14. MicroSteff – big software system for the mac Big software program V.1.5.1 Jan/2007 Jan/2007 Verdatim DataLife MF2-HD 1.44 MB Here! Test This! My first “professional” job A stack of computer printouts—and no documentation

  15. Cost of Testing You’re going to spend at least half of your development budget on testing, whether you want to or not • In the real-world, testing is the principle post-design activity • Restricting early testing usually increases cost • Extensive hardware-software integration requires more testing

  16. Cost of Late Testing 60 Assume $1000 unit cost, per fault, 100 faults 50 40 Fault origin (%) Fault detection (%) Unit cost (X) 30 20 10 0 Requirements Design Prog / Unit Test Integration Test System Test Post-Deployment $6K $13K $20K $100K $360K $250K Software Testing Institute; Carnegie Mellon University; Handbook CMU/SEI-96-HB-002

  17. Cost of Not Testing Program Managers often say: “Testing is too expensive.” • Not testing is even more expensive • Planning for testing after development is prohibitively expensive • A test station for circuit boards costs half a million dollars … • Software test tools cost less than $10,000 !!!

  18. Lessons • Many errors are made in the early phases • These errors are discovered late • Repairing those errors is costly •  It pays off to start testing real early

  19. Summary: Why Do We Test Software ? A tester’s goal is to eliminate faults as early as possible • Improve quality • Reduce cost • Preserve customer satisfaction

  20. How then to proceed? • Exhaustive testing most often is not feasible • Random statistical testing does not work either if you want to find errors • Therefore, we look for systematic ways to proceed during testing

  21. State-of-the-Art on Faults • 30-85 errors are made per 1000 lines of source code • extensively tested software contains 0.5-3 errors per 1000 lines of source code • testing is postponed, as a consequence: the later an error is discovered, the more it costs to fix it. • error distribution: 60% design, 40% implementation. 66% of the design errors are not discovered until the software has become operational.

  22. How Faults are introduced • In software development projects, a “software fault" can be introduced at any stage during development. • Faults are a consequence of the nature of human factors during development. They arise from oversights or mutual misunderstandings made by a software team during specification, design, coding, data entry and documentation. • More complex faults can arise from unintended interactions between different parts of the software, the operating systems and the computer network. • 66% of the design errors are not discovered until the software has become operational.

  23. Most Common Software problems • Incorrect calculation • Incorrect data edits & ineffective data edits • Incorrect matching and merging of data • Data searches that yields incorrect results • Incorrect processing of data relationship • Incorrect coding / implementation of business rules • Inadequate software performance

  24. Most Common Software problems • Confusing or misleading data • Software usability by end users & Obsolete Software • Inconsistent processing • Unreliable results or performance • Inadequate support of business needs • Incorrect or inadequate interfaces with other systems • Inadequate performance and security controls • Incorrect file handling

  25. Types of bugs • Arithmetic bugs • Division by zero. • Arithmetic overflow or underflow. • Loss of arithmetic precision due to rounding or numerically unstable algorithms. • Resource bugs • Null pointer dereference. • Using an uninitialized variable. • Using an otherwise valid instruction on the wrong data type (see packed decimal/binary coded decimal). • Access violations. • Resource leaks, where a finite system resource (such as memory or file handles) become exhausted. • Buffer overflow. • Excessive recursion.

  26. Types of bugs • Logic bugs • Infinite loops and infinite recursion. • Off by one error, counting one too many or too few when looping. • Syntax bugs: Those found by the compilers. • Multi-threading programming bugs • Dedlock. • Race condition. • Concurrency errors. • Interfacing bugs. • Incorrect hardware handling. • Performance bugs • Teamworking bugs

  27. Some preliminary questions • What exactly is an error? • How does the testing process look like? • When is test technique A superior to test technique B? • What do we want to achieve during testing? • When to stop testing?

  28. Software Faults, Errors & Failures • Software Fault : A static defect in the software • Software Error : An incorrect internal state that is the manifestation of some fault • Software Failure : External, incorrect behavior with respect to the requirements or other description of the expected behavior

  29. A Concrete Example Fault: Should start searching at 0, not 1 public static int numZero (int [ ] arr) { // Effects: If arr is null throw NullPointerException // else return the number of occurrences of 0 in arr int count = 0; for (int i = 1; i < arr.length; i++) { if (arr [ i ] == 0) { count++; } } return count; } Test 1 [ 2, 7, 0 ] Expected: 1 Actual: 1 Error: i is 1, not 0, on the first iteration Failure: none Test 2 [ 0, 2, 7 ] Expected: 1 Actual: 0 Error: i is 1, not 0 Error propagates to the variable count Failure: count is 0 at the return statement

  30. Dynamics of Faults • Fault Detection: “Waiting” or causing (or finding) for the error or failure to ocurr. • Fault Location: Finding where the fault(s) ocurred, its causes and its consequences. • Fault Recovery: Fixing the fault and NOT causing others. • Regresion Testing: Testing the software again with the same data that caused the original fault

  31. Verification and Validation • Verification: evaluate a product to see whether it satisfies the conditions specified at the start: • Have we built the system right? • Validation: evaluate a product to see whether it does what we think it should do: • Have we built the right system?

  32. What is our goal during testing? • Objective 1: find as many faults as possible • Objective 2: make you feel confident that the software works OK • Objective 3: make sure that the software fulfills its specification. • Objective 4: make sure that the customer approves the software. Do we know what to test and how to test it ?

  33. The structure of a software test plan • The testing process. • Requirements traceability. • Tested items. • Testing schedule. • Test recording procedures. • Hardware and software requirements. • Constraints.

  34. Static and dynamic verification • Software inspections. Concerned with analysis of the static system representation to discover problems (static verification) • May be supplement by tool-based document and code analysis • Software Testing. Concerned with exercising and observing product behaviour (dynamic verification) • The system is executed with test data and its operational behaviour is observed. • Used to Detect Faults. • Software Debugging. Concerned with finding and removing the faults. • Fault Tolerance. If faults still ocurr during operation: detect, remove and recover the system from faults.

  35. Software inspections • These involve people examining the source representation with the aim of discovering anomalies and defects. • Inspections not require execution of a system so may be used before implementation. • They may be applied to any representation of the system (requirements, design,configuration data, test data, etc.). • They have been shown to be an effective technique for discovering program errors.

  36. Inspection checklists • Checklist of common errors should be used to drive the inspection. • Error checklists are programming language dependent and reflect the characteristic errors that are likely to arise in the language. • In general, the 'weaker' the type checking, the larger the checklist. • Examples: Initialisation, Constant naming, loop termination, array bounds, etc.

  37. Inspection checks 1

  38. Inspection checks 2

  39. Stages of static analysis • Control flow analysis. Checks for loops with multiple exit or entry points, finds unreachable code, etc. • Data use analysis. Detects uninitialised variables, variables written twice without an intervening assignment, variables which are declared but never used, etc. • Interface analysis. Checks the consistency of routine and procedure declarations and their use

  40. Stages of static analysis • Information flow analysis. Identifies the dependencies of output variables. Does not detect anomalies itself but highlights information for code inspection or review • Path analysis. Identifies paths through the program and sets out the statements executed in that path. Again, potentially useful in the review process • Both these stages generate vast amounts of information. They must be used with care.

  41. The Software Testing process

  42. Testing process goals • Validation testing • To demonstrate to the developer and the system customer that the software meets its requirements; • A successful test shows that the system operates as intended. • Defect testing • To discover faults or defects in the software where its behaviour is incorrect or not in conformance with its specification; • A successful test is a test that makes the system perform incorrectly and so exposes a defect in the system.

  43. The testing phases • Component (unit) testing • Testing of individual program components; • Usually the responsibility of the component developer (except sometimes for critical systems); • Tests are derived from the developer’s experience. • System testing • Testing of groups of components integrated to create a system or sub-system; • The responsibility of an independent testing team; • Tests are based on a system specification.

  44. Testing phases

  45. Component testing • Component or unit testing is the process of testing individual components in isolation. • It is a defect testing process. • Components may be: • Individual functions or methods within an object; • Object classes with several attributes and methods; • Composite components with defined interfaces used to access their functionality.

  46. System testing • Involves integrating components to create a system or sub-system. • May involve testing an increment to be delivered to the customer. • Two phases: • Integration testing - the test team have access to the system source code. The system is tested as components are integrated. • Release testing - the test team test the complete system to be delivered as a black-box.

  47. Integration testing • Involves building a system from its components and testing it for problems that arise from component interactions. • Top-down integration • Develop the skeleton of the system and populate it with components. • Bottom-up integration • Integrate infrastructure components then add functional components. • To simplify error localisation, systems should be incrementally integrated.

  48. Incremental integration testing

  49. Interface testing • Objectives are to detect faults due to interface errors or invalid assumptions about interfaces. • Particularly important for object-oriented development as objects are defined by their interfaces.

  50. Interface testing