0% found this document useful (0 votes)
60 views8 pages

Lesson 8 Digi Trailblazers Course 2

Uploaded by

Saqib Tipo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views8 pages

Lesson 8 Digi Trailblazers Course 2

Uploaded by

Saqib Tipo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Lesson 8 - Testing and Improving Programs 3

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:

• How to test for logic errors

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:

Let’ s print ('\n\nSENIOR MEMBERSHIP')


Again = input('\n\nProcess another Membership Card? Enter Y or N: ')
And Lookis e at the steps for a logic test
Again = Again.upper()
c t print ('\n\nProgram Ending......’)
04 Pra shown in the example.
Key the code into Python, debug it and run the program.
Activity 1 – continued
The following shows the four lines of code which need to be tested for logic:

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.

<= 16 - you test 15 (valid), 16 (valid), 17 (invalid)

Conduct the test and


record the results.

Now create a blank test


plan to test the logic of the
program you created in
Lessons 4 to 6.

Use the debugging tool


you were introduced to in
Lesson 6.
06
• Functional testing
• is where the solution created is checked against the original

Lesson Summary problem to make sure that it contains the functionality


needed to solve the problem.
• Operational testing
– Understand • Testing calculations to make sure that the answers
calculated are correct.
How to Test for •

Calculations should be tested at least twice.
Use the line numbers to identify which bit of the code is
Functional and •
being tested.
Expected and actual results should be recorded and any

Operational actions taken to correct code should be noted

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

You might also like