Lesson 8 Digi Trailblazers Course 2
Lesson 8 Digi Trailblazers Course 2
Course 2
Inspiring the next generation of digital innovators
Lesson 8 – Testing and Improving
Programs 3
By the end of the lesson you will understand:
03
Activity 1
• We have looked at testing the functionality # logictesting.py
and operational content of code we have # This program presents an opportunity to test both a loop and a
# selection construct.
written.
• The logic behind a code also needs to be import os
import string
tested.
• Program logic is tested by following and Age = 0
Again = 'Y'
testing every path of the program that will run
during execution. while (Again == 'Y'):
os.system('clear')
• The test data should test every boundary print ('MEMBERSHIP CARD CREATOR')
(above and below as well as the actual print ('\n\nThis system creates a membership card based on your age')
print ('------------------\n')
border value). Age = int(input('Please input your age: '))
• Planning a logic test can be complex if (Age <=16):
print ('\n\nJUNIOR MEMBERSHIP')
because of the amount of parts that need to else:
be tested. if (Age <= 60):
print ('\n\nADULT MEMBERSHIP')
C o de else:
05
Activity 1 – continued
Look at the test plan below.
The data chosen is testing for valid/invalid inputs and testing the boundaries of the condition for each selection.
Errors
07
NCC Education Head South Africa Malaysia China Singapore
Office UK 1 Bridgeway Road Unit No.C-7-4 LG2-T1, Tower C 100 Victoria Street
The Towers Bridgeways Precinct Wisma Goshen, Plaza Pantai COFCO Plaza #13-01/02
Towers Business Park Century City No.5 Persiaran Pantai Baru No. 8 Jianguomennei Avenue National Library Building
Wilmslow Road Cape Town 59200 Kuala Lumpur Dongcheng District Singapore
Didsbury 7441 Malaysia Beijing 100005 188064
Manchester M20 2EZ South Africa China
United Kingdom
+27 21 830 5242 +60 3 2284 6200 +86 10 6520 4030 +65 6580 4555
+44 (0) 161 438 6200
Monday to Friday Monday to Friday Monday to Friday Monday to Friday
Monday to Friday 08:30 – 17:00 09:00 – 17:00 09:30 – 18:30 09:30 – 17:00
08:30 – 17:00