[INF43] Lecture 12 Testing part2

软件工程 SoftwareEngineering


@ZYX 写于2020年05月19日

Testing curve

Ways to choose test cases

  1. Intuition
  2. specification black
    1. know something what should they behaved then write the tests
  3. code (white-box testing)
    1. make sure the every line of code works
  4. Existing test cases (regression test)
    1. after making some changes, rerun the previous tests to make sure they can pass
  5. Faults
    1. based on experience, test the area that are likely to have bugs

Test Oracles

  • A mechanism for deciding whether a test case execution succeeds or fails
    • Difficult to automate
  • just something you use to decide what to test
  1. 有时候很难写test
    • 如何测试 cos(0.5)=0.877582561? 我们有时很难知道这种inputs应该有什么输出;


  • Every software has bugs

How do we know we are done testing

  • Aim to reveal as many faults as possible in a fixed period of time with a fixed budget
    • Target specific areas of the system
  • Aim to meet the quality requirements established for the project
  • Every time you find bugs indicating you have more bugs

Seeding Method

  • Pepper the code with defects and observe how many of the seeded defects are discovered
    • From this, infer how many bugs are left to find
  • This technique assumes that non-seeded defects are similar to the seeded ones