Year 9 · Summer 2

Raid: Capstone · Lesson 4 of 5

Testing against success criteria

PracticalTopic 14 Programming further

Year 9 · Raid: Capstone · Lesson 4 of 5

You will learn to

  • Write a test table with at least one test for each success criterion.
  • Choose normal, boundary and erroneous test data, and write the expected result before testing.
  • Use another guild's test run to find failures.
  • Fix what fails, and run the failed tests again.

Year 9 · Raid: Capstone · Lesson 4 of 5

Success criteria

You have got it when you can say:

  • I can write input, expected, actual and pass or fail for every test.
  • I can pick boundary data for a range, like 0, 255, -1 and 256.
  • I can show a test that failed, the fix, and the same test passing.

Year 9 · Raid: Capstone · Lesson 4 of 5

Retrieval starter

Questions from before. Write your answers, then show them.

  1. Last lesson

    A variable made inside a function is…

    A Local: only exists inside it while it runsB Saved to a fileC Global: usable anywhere

    A. Local: only exists inside it while it runs

  2. Last unit

    A half adder is made from…

    A a NOT gate and an OR gateB two OR gatesC an XOR gate and an AND gate

    C. an XOR gate and an AND gate

  3. Earlier this year

    Double the width and the height. The file becomes…

    A 2 times biggerB 4 times bigger

    B. 4 times bigger

Year 9 · Raid: Capstone · Lesson 4 of 5

Key words (1 of 2)

Boundary
Test data at the very edge of what's allowed.
List
One name holding many values in order. Also called an array.
Index
An item's position in a list, counting from 0.
Subroutine
A named block of code you can call when needed.

Year 9 · Raid: Capstone · Lesson 4 of 5

Key words (2 of 2)

Function
A subroutine that returns a value.
Parameter
A placeholder in a subroutine for a value passed in.
Validation
Checking input is reasonable before using it.
Boundary data
Test data at the very edge of what's allowed.

The explanation · step 1 of 1

Testing

For a program that accepts a score from 0 to 50:

Test dataMeaningExamplesExpected
NormalSensible data23, 38Accepted
BoundaryAt the very edges0, 50 (and -1, 51)0 and 50 accepted; -1, 51 rejected
ErroneousWrong type or nonsense"hello", 3.7, blankRejected with a message
★Remember

A test plan is written before testing: what you'll test, the data, the expected result.

Year 9 · Raid: Capstone · Lesson 4 of 5

Try it: Test the score checker (0 to 50)

Year 9 · Raid: Capstone · Lesson 4 of 5

Quick quiz · 1 of 3

open("log.txt", "w") on a file that already holds 100 lines…

  1. A Adds to the end
  2. B Gives an error
  3. C Wipes it first

C. Wipes it first

"w" empties the file before writing. Use "a" to append.

Year 9 · Raid: Capstone · Lesson 4 of 5

Quick quiz · 2 of 3

The program runs but gives the wrong answer. That's a…

  1. A Runtime error
  2. B Syntax error
  3. C Logic error

C. Logic error

The code is valid and doesn't crash; the thinking is wrong. Only testing finds it.

Year 9 · Raid: Capstone · Lesson 4 of 5

Quick quiz · 3 of 3

Program runs but gives the wrong answer. That's a…

  1. A Logic error
  2. B Syntax error

A. Logic error

The code is valid; the thinking is wrong.

Year 9 · Raid: Capstone · Lesson 4 of 5

Exit ticket

Answer on paper before you go. Then check.

  1. In ["a", "b", "c"], the index of "c" is…

    A cB 2C 3

    B. 2 Counting starts at 0: a = 0, b = 1, c = 2.

  2. word = "Python". What is word[1:4]?

    A "yth"B "ytho"C "Pyth"

    A. "yth" Start at index 1 (y), stop before index 4 (o): y, t, h. That's 4 − 1 = 3 characters.