1 / 12

Advanced Material

Advanced Material. The following slides contain advanced material and are optional. Outline. Testing What is testing Unit testing Automatic testing. Program verification. Verification checks validity of a program by Testing (here, functional testing on class level) Proving Testing

holt
Download Presentation

Advanced Material

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Material The following slides contain advanced material and are optional.

  2. Outline • Testing • What is testing • Unit testing • Automatic testing

  3. Program verification • Verification checks validity of a program by • Testing (here, functional testing on class level) • Proving • Testing • Execute a program to check if it works • Verifies one particular execution of a program • Applicable to no/partial specification • Proving • Program is statically checked (not executed) • Verifies every possible execution • Needs complete specification

  4. Testing • Execute program • Manual testing • Unit testing • Automatic testing • If a test is successful: • The program works with exactly this input • The program could still fail with different input • If a test fails: • Bug found in program • A good test is a test that fails!

  5. Unit testing • Write test for a „unit“ of source code: • In object-oriented code, mostly per routine or class • Each test case has three steps • Prepare environment • Run test case • Evaluate output • Library support exists for all major languages

  6. Demo

  7. Automatic testing • Generate test cases automatically • Need a way to generate valid input data • Need a way to check validity of output data • Any ideas? • Input to a routine is valid if precondition is satisfied • Output of a routine is valid if postcondition is satisfied

  8. Automatic input generation • Create objects at random by • Calling a creation routine • Calling commands on the object • These objects can then be used to test a routine • Call routine with random input data (in case of basic types like integer) • Call routine with random objects, created as mentioned above

  9. Validate input • Check if randomly chosen objects satisfy precondition • If yes, this is a valid test case • If no, ignore this test case

  10. Evaluate output • For a valid test case, check if postcondition is satisfied • If yes, the test was successful • If no, there is a bug in the routine • Test also fails if • any exception happens during routine evaluation, e.g. Void-call or Precondition violation

  11. Demo

More Related