{"base":{"id":"cs8-30","subject":"Programming","title":"Testing a program","scene":"pycode","steps":[{"mode":"plan","eyebrow":"Test plans","title":"Expected, then actual","body":"A test plan lists test inputs and the expected result for each, written before running. Then you record the actual results. Run the tests, fix the bug, and run them all again.","actions":[{"id":"run","label":"Run the tests"},{"id":"fix","label":"Fix: use >= 8"}]},{"mode":"data","eyebrow":"Test data","title":"Normal, boundary, invalid","body":"One successful test isn't enough. Good test data includes normal values, boundary values at the edges, invalid values and the wrong type. Add each kind of test.","actions":[{"id":"normal","label":"Normal"},{"id":"boundary","label":"Boundary"},{"id":"invalid","label":"Invalid"},{"id":"wrongType","label":"Wrong type"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Boundary test","body":"A game allows scores from 0 to 100.","question":"Which pair are boundary tests?","options":["0 and 100","50 and 60","\"abc\" and \"xyz\""],"answer":0,"right":"Correct. They sit exactly on the edges of the allowed range.","wrong":"Not quite. Where are the edges of the range?","look":"plan"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"If it works once, it works.\"","body":"One test checks one path. The age program worked for 12 but failed for 8."},{"tag":"Popular idea","title":"\"You test after the program is finished.\"","body":"Plan tests early and test in every cycle of development."},{"tag":"Popular idea","title":"\"A failed test is bad news.\"","body":"It's good news: you found the bug before your users did."}]},{"type":"cards","id":"kinds","eyebrow":"Test data","title":"Four kinds of test data","items":[{"tag":"Normal","title":"Typical values","body":"Values well inside the range: 10, 12, 14."},{"tag":"Boundary","title":"The edges","body":"Exactly on the limits, and just outside: 8, 16, 7, 17."},{"tag":"Invalid","title":"Wrong value","body":"Right type, outside the range: 5, 20. Should be refused."},{"tag":"Wrong type","title":"Wrong kind","body":"Text such as \"ten\" or a blank. Should give a helpful message."}]},{"type":"cards","id":"steps","eyebrow":"The method","title":"Testing step by step","items":[{"tag":"1","title":"Plan","body":"Write inputs and expected results first."},{"tag":"2","title":"Run","body":"Run each test and record the actual result."},{"tag":"3","title":"Compare","body":"Mark pass or fail."},{"tag":"4","title":"Fix and re-test","body":"Fix bugs, then run every test again."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Test the tester","items":[{"title":"Break a rule","time":"15 minutes","need":["Paper and a pen","A family member"],"steps":["Ask someone to make up a secret rule, e.g. 'numbers from 20 to 50 are OK'.","Write a test plan: 2 normal, 4 boundary, 2 invalid, 1 wrong type, each with your expected answer.","Say each test input; they answer 'OK' or 'not OK'.","Which tests told you the most about the rule?"],"why":"Boundary tests usually reveal the exact limits, which is why programmers always include them.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"When should expected results be written?","options":["After seeing the actual results","Before running the tests","Never"],"answer":1,"right":"Correct. So you can't be fooled by what happened.","wrong":"Not quite. Why write them first?"},{"question":"Rule: ages 8 to 16. Which is an invalid test?","options":["12","8","20"],"answer":2,"right":"Correct. 20 is outside the range.","wrong":"Not quite. Which is outside the range?"},{"question":"Rule: ages 8 to 16. Which is a wrong-type test?","options":["16","\"twelve\"","7"],"answer":1,"right":"Correct. Text instead of a number.","wrong":"Not quite. Which isn't a number?"},{"question":"A test's actual result differs from the expected result. This means…","options":["there may be a bug","the test passed","the computer is broken"],"answer":0,"right":"Correct. Investigate and fix.","wrong":"Not quite. What does a fail tell you?"},{"question":"After fixing a bug you should…","options":["delete the test plan","run all the tests again","only run the failed test"],"answer":1,"right":"Correct. A fix can break something else.","wrong":"Not quite. Could the fix break another test?"},{"question":"Why include boundary tests?","options":["They are the easiest","They never fail","Many bugs happen at the edges"],"answer":2,"right":"Correct. > versus >= mistakes show up there.","wrong":"Not quite. Think about the age bug."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["what a test plan contains","why expected results are written before testing","the four kinds of test data","why one successful test is not enough","why every test is run again after a fix"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"test plan","meaning":"A table of test inputs, expected results and actual results."},{"word":"expected result","meaning":"What should happen, written before testing."},{"word":"actual result","meaning":"What really happened."},{"word":"boundary data","meaning":"Values on or just past the edges of a range."},{"word":"invalid data","meaning":"Values the program should refuse."},{"word":"bug","meaning":"A mistake in a program."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize GCSE Computer Science: Testing"]}]},"overlay":null}