nus-cs3281 / 2017

A repo to hold info on CS3281 students
2 stars 1 forks source link

Property-based testing #41

Closed Neurrone closed 7 years ago

Neurrone commented 7 years ago

Outline:

Slides available here

Neurrone commented 7 years ago

PUMA outline:

  1. Audience: fellow CS3281/2 students
  2. Objective: To encourage use of property-based testing
  3. Topic: Find the bugs you're missing with property-based testing
  4. PUNCH: Question: When writing tests, have you ever wished that the computer could come up with test cases itself?
  5. WIIFY: Learn how you can find more bugs and make your tests really work for you.
  6. Promise:
    • WHAT is property-based testing?
    • WHY is it worth doing?
    • HOW to go about doing it?
  7. Content:
    • WHAT is property-based testing?
      • making statements about output of code, and having these statements/properties verified for many randomly generated inputs
      • Key point: test cases generated by computer, which tries its best to produce failures
    • WHY property-based testing is worth doing?
      • Stress-tests your program with many test cases that you don't have to manually come up with
      • Finds suttle bugs that would be missed by example-based testing
      • Support: demonstrate with Hypothesis demo
      • Key point: Property-based testing is worth doing because it lets you write software with less bugs
    • HOW to go about doing it?
      • hypothesis demo
      • Concerns:
        • how to specify properties? Demo with examples
        • Since inputs are randomly generated, if a test run finds a failure, is it remembered so that future runs test this case? Yes.
        • is this available in my language? Probably
      • Key point: It’s doable, though it may require some practice
  8. Key points / summary statement / elevator pitch
    • Property-based testing is about stating properties about output of code, based on the input, and having these properties verified for many possible inputs
    • Stress-test your program with many tests to discover suttle bugs without requiring much manual effort
    • Good Complement to example-based testing
    • Worth doing, not hard to get started
  9. Call to action: Let’s start using property-based testing

Do: start using property-based testing Believe: using property-based testing is worth it, even if it forces you to think harder Know: What is property-based testing, property-based testing vs example-based testing, how to specify properties