Testing Overview

download Testing  Overview

of 41

  • date post

    13-Jan-2016
  • Category

    Documents

  • view

    34
  • download

    0

Embed Size (px)

description

Testing Overview. Why Test?. Before you begin designing tests, it ’ s important to have a clear understanding of why you are testing In general, you test for four reasons: 􀂃 To find bugs in software (testing is the only way to do this) 􀂃 To reduce risk to both users and the company - PowerPoint PPT Presentation

Transcript of Testing Overview

  • Testing Overview

  • Why Test?Before you begin designing tests, its important to have a clear understanding of why you are testingIn general, you test for four reasons: To find bugs in software (testing is the only way to do this) To reduce risk to both users and the company To reduce development and maintenance costs To improve performance

  • To Find the BugsOne of the earliest important results from theoretical computer science is a proof (known as the Halting Theorem) that its impossible to prove that an arbitrary program is correct. Given the right test, however, you can prove that a program is incorrect (that is, it has a bug).

  • To Reduce RiskThe objectives in testing are to demonstrate to yourself (and regulatory agencies, if appropriate) that the system and software works correctly and as designed.In short, you want to discover every conceivable fault or weakness in the system and software before its deployed in the field.

  • To Reduce CostsThe earlier a bug is found, the less expensive it is to fix. The cost of finding errors and bugs in a released product is significantly higher than during unit testing, for example (see Figure 9.1).

  • To Improve PerformanceFinding and eliminating dead code and inefficient code can help ensure that the software uses the full potential of the hardware and thus avoids the dreaded hardware re-spin.

  • When to Test?It should be clear from Figure 9.1 that testing should begin as soon as feasible.Usually, the earliest tests are module or unit tests conducted by the original developer.Unfortunately, few developers know enough about testing to build a thorough set of test cases.Because carefully developed test cases are usually not employed until integration testing, many bugs that could be found during unit testing are not discovered until integration testing.

  • Unit TestingIndividual developers test at the module level by writing stub code to substitute for the rest of the system hardware and software. At this point in the development cycle, the tests focus on the logical performance of the code.Typically, developers test with some average values, some high or low values, and some out-of-range values (to exercise the codes exception processing functionality).Unfortunately, these black-box derived test cases are seldom adequate to exercise more than a fraction of the total code in the module.

  • Regression TestingIt isnt enough to pass a test once. Every time the program is modified, it should be retested to assure that the changes didnt unintentionally break some unrelated behavior. Called regression testing, these tests are usually automated through a test script.

  • Which Tests?Because no practical set of tests can prove a program correct , the key issue becomes what subset of tests has the highest probability of detecting the most errors, as noted in The Art of Software Testing by Glen Ford Myers[6].Although dozens of strategies exist for generating test cases, they tend to fall into two fundamentally different approaches: functional testing and coverage testing.Functional testing (also known as black-box testing) selects tests that assess how well the implementation meets the requirements specification. Coverage testing (also known as white-box testing) selects cases that cause certain portions of the code to be executed.

  • Which Tests?(ctd)Both kinds of testing are necessary to test rigorously your embedded design. Coverage testing implies that your code is stable, so it is reserved for testing a completed or nearly completed product. Functional tests, on the other hand, can be written in parallel with the requirements documents.

  • Which Tests?(ctd)The following is a simple process algorithm for integrating your functional and coverage testing strategies:1. Identify which of the functions have NOT been fully covered by the functional tests.2. Identify which sections of each function have not been executed.3. Identify which additional coverage tests are required.4. Run new additional tests.5. Repeat.

  • When to Stop?The most commonly used stop criteria (in order of reliability) are: When the boss says When a new iteration of the test cycle finds fewer than X new bugs When a certain coverage threshold has been met without uncoveringany new bugs

  • Choosing Test CasesIn the ideal case, you want to test every possible behavior in your program. This implies testing every possible combination of inputs or every possible decision path at least once.As youll see, a combination of functional testing and coverage testing provides a reasonable second-best alternative. The basic approach is to select the tests (some functional,some coverage) that have the highest probability of exposing an error.

  • Functional TestsFunctional testing is often called black-box testing because the test cases for functional tests are devised without reference to the actual code that is, without looking inside the box.Black-box tests are based on what is known about which inputs should be acceptable and how they should relate to the outputs.

  • Functional Tests(ctd)Example black-box tests include: Stress tests: Tests that intentionally overload input channels, memory buffers, disk controllers, memory management systems, and so on. Boundary value tests: Inputs that represent boundaries within a particular range (for example, largest and smallest integers together with 1,0, +1, for an integer input) and input values that should cause the output to transition across a similar boundary in the output range. Exception tests: Tests that should trigger a failure mode or exception mode. Error guessing: Tests based on prior experience with testing software or from testing similar programs. Random tests: Generally, the least productive form of testing but still widely used to evaluate the robustness of user-interface code. Performance tests: Because performance expectations are part of the product requirement, performance analysis falls within the sphere of functional testing.

  • Functional Tests(ctd)Because black-box tests depend only on the program requirements and its I/O behavior, they can be developed as soon as the requirements are complete. This allows black-box test cases to be developed in parallel with the rest of the system design.Like all testing, functional tests should be designed to be destructive, that is, to prove the program doesnt work.

  • Functional Tests(ctd)As an R&D product manager, this was one of my primary test methodologies. If 40 hours of abuse testing could be logged with no serious or critical defects logged against the product, the product could be released. If a significant defect was found, the clock started over again after the defect was fixed.

  • Coverage TestsThe weakness of functional testing is that it rarely exercises all the code. Coverage tests attempt to avoid this weakness by (ideally) ensuring that each code statement, decision point, or decision path is exercised at least once. (Coverage testing also can show how much of your data space has been accessed.)Also known as white-box tests or glass-box tests, coverage tests are devised with full knowledge of how the software is implemented, that is, with permission to look inside the box.White-box tests depend on specific implementation decisions, they cant be designed until after the code is written.

  • Coverage Tests(ctd)Example white-box tests include: Statement coverage: Test cases selected because they execute every statement in the program at least once. Decision or branch coverage: Test cases chosen because they causeevery branch (both the true and false path) to be executed at least once. Condition coverage: Test cases chosen to force each condition (term) in a decision to take on all possible logic values.

  • Gray-Box TestingWhite-box tests can be intimately connected to the internals of the code, they can be more expensive to maintain than black-box tests.Tests that only know a little about the internals are sometimes called gray-box tests. Gray-box tests can be very effective when coupled with error guessing.These tests are gray box because they cover specific portions of the code; they are error guessing because they are chosen based on a guess about what errors are likely. This testing strategy is useful when youre integrating new functionality with a stable base of legacy code.

  • Testing Embedded SoftwareGenerally the traits that separate embedded software from applications software are: Embedded software must run reliably without crashing for long periods of time. Embedded software is often used in applications in which human lives are at stake. Embedded systems are often so cost-sensitive that the software has little or no margin for inefficiencies of any kind. Embedded software must often compensate for problems with the embedded hardware. Real-world events are usually asynchronous and nondeterministic, making simulation tests difficult and unreliable. Your company can be sued if your code fails.

  • Testing Embedded Software(ctd)Because of these differences, testing for embedded software differs from application testing in four major ways. First, because real-time and concurrency are hard to get right, a lot of testing focuses on real-time behavior. Second,because most embedded systems are resource-constrained real-time systems,more performance and capacity testing are required. Third, you can use some realtime trace tools to measure how well the tests are covering the code. Fourth, youll probably test to a higher level of reliability than if you were testing application software.

  • Dimensions of IntegrationThe integration phase really has three dimensions to it:hardware, software, and real-time.Suffice to s