program-testing-and-debugging-kiHLkLdx
program-testing-and-debugging-kiHLkLdx
1.Learning Outcomes
2. Overview
Review Questions
Lesson 1 of 9
1.Learning Outcomes
2. Overview
Exhaustive testing is a test approach in which all combinations of inputs and preconditions are
used to test a software.
Most of the time, it is not feasible to perform exhaustive testing as the possible permutation of
inputs may be too large. It is very time consuming and tedious to test through all the possible
inputs. It may also be a challenge to anticipate all possible inputs and preconditions that may
occur.
Given a test which consists of 10 MCQs with a passing mark 0f 50. Each MCQ carries 10 marks.
A software is written to determine whether a particular student passed or failed the test. The
software accepts the input of the student's MCQ test mark and display whether the student has
passed or failed the test.
An example of exhaustive testing would be to test all the possible marks a student may get in
the MCQ test. The following video illustrates all the test inputs being fed into the software to
evaluate the result.
Lesson 4 of 9
Boundary testing is a test approach in which test inputs are generated using
Boundary testing is used to test all the designed software ow of execution. The inputs are used
to evaluate whether the software is owing as intended and executing correctly.
Using the same MCQ test example illustration in Exhaustive testing, instead of using all the
possible inputs to test, Boundary testing make use of lesser inputs to test all the designed
software ow of execution.
The following video illustrates boundary test inputs being fed into the software to evaluate the
result.
WH AT I S B O UN DA R Y T E ST I N G? E X A MPL E I L L UST R AT I O N B O UN DA R Y I N PUT S
In the example, the maximum mark possible is 100 and the minimum mark is 0. Thus 100 and
0 are part of the boundary input values.
The passing mark is 50 and this value is at the boundary where the outcome may change from
Pass or Fail. Corner values are the values near to 50 which will result in di erent outcomes. So
50 and 40 are all called the corner values. 50 will result in the outcome Pass and 40 will result
in the outcome Fail.
Exercise
Given a simple software that computes the price of an item. It rst prompts the user for the
day of week and then computes the price to pay.
Click on the SoloLearn "BoundaryTest" below. Analyse and test the codes there. What is the
boundary values to be used to test this software?
BoundaryTest
Check out what Roy has created on SoloLearn
READ MORE SOLOLEARN
1 - Minimum value
5 - Corner value
6 - Corner value
7 - Maximum value
Lesson 5 of 9
True
False
What is debugging?
Debugging is a process of tracing software problems to isolate the cause and resolving the
problem.
A software that is giving a wrong outcome or behaving incorrectly is said to be having a bug.
That is why when a software programmer is trying to solve the problem, he is deemed to be
trying to remove the bug which give rise to the term debug.
There are various debugging techniques which may be used depending on circumstances.
Trace Messages
Log les
Debugger
What is an IDE
An integrated development environment (IDE) is a software used by a programmer to
write codes
Way to operate
Additional features
Debugger
A debugger is a tool within the IDE that a software programmer can use to trace their
program execution. A debugger can be used to understand how a program ow (written by
other programmer) or to isolate a software bug.
A software programmer can choose to run the codes in normal mode or debug mode. When
there are some software bugs, the programmer can run in debug mode to use the debugger.
Breakpoints
Single Stepping
Watches
Breakpoint
A breakpoint is a point in the codes where the debugger will pause to allow the programmer
to trace and investigate on a software bug.
The programmer can set one or multiple breakpoints within the codes to investigate what's
wrong with the program.
Single Stepping
A debugger allows the programmer to trace the program code execution line by line. This is
known as single stepping the program.
Single stepping is useful for the programmer to trace the status of the variables to isolate the
cause of a software bug.
There are 2 Single Stepping commands to run the code line by line.
Watch
A watch allows the programmer to keep watch of the value of selected variable and/or
expression.
The programmer can add multiple watches to keep various variables in view during code
execution to isolate on cause of a bug.
PyCharm Debugger
This section shows videos on how to use the debugger from the PyCharm (IDE). After looking
at the video, you may also want to follow the steps here to familirise with the debugger.
go to debug mode
add a breakpoint
single step
add a watch
This video illustrate using a debugger through a program dealing with prime numbers.
Debug Exercise 1
Type the following codes at the IDE.
base = 5;
height = 10;
half = 1//2;
areaOfTriangle = half * base * height;
print("Area of our triangle is ",areaOfTriangle)
# expected output should be
# Area of our triangle is 25.0
Debug program 01
The expected output should show Area of our triangle is 25.0 but there is a bug in the codes.
Use Breakpoints and Single Stepping to nd out the problem and solve it.
Debug Exercise 2
Type the following codes at the IDE.
totalSecs = 128
mins = totalSecs / 60
secs = 128 - mins * 60
print(" 128 secs = ",mins ," mins ", secs," secs")
# expected output should be
# 128 secs = 2 mins 8 secs
Debug program 02
The expected output should show 128 secs = 2 mins 8 secs but there is a bug in the codes.
Use Breakpoints and Single Stepping to nd out the problem and solve it.
Lesson 8 of 9
Review Questions
Question
01/10
Which of the following is not a reason for you to perform unit testing?
02/10
03/10
It's test inputs are generated using the minimum and maximum
input values
It's test inputs are generated using the corner values that would
cause a change in the outcome
Question
04/10
05/10
Write codes
06/10
Breakpoint
Single Stepping
Watches
07/10
_____ is a point in the codes where the debugger will pause to allow the
programmer to trace and investigate on a software bug.
IDE
Breakpoint
Single Stepping
Watch
Question
08/10
_____ is a feature that allows the programmer to trace the program code
execution line by line.
IDE
Breakpoint
Single Stepping
Watch
Question
09/10
_____ is a feature that allows the programmer to keep monitor the value of
selected variable and/or expression.
IDE
Breakpoint
Single Stepping
Watch
Question
10/10
Give a reason in which you will need to use Step-Into instead of Step-Over
during Single Stepping?