Download Session 4-Test 2 practical.pptx and more Essays (university) Law in PDF only on Docsity!
Session 4
Testing basics
Objectives
• Applying tests in SDLC
• Understanding testing
• Understanding and being able to use black box testing
- (^) Writing test cases
- (^) Evaluating actual test results
• Understanding and being able to use white box testing
- (^) Writing test cases
- (^) Evaluating actual test results
• Acceptance Testing
Defining a test case
• By IEEE documentation standard #829-
– A set of test inputs, execution conditions, and
expected results developed for a particular
objective, such as to exercise a particular program
path or to verify compliance with a specific
requirement.
– Documentation specifying inputs, predicted
results, and a set of execution conditions for a test
item.
Test approaches
• One of the important phases software
development life cycle is testing
• The aim of testing is
– To investigate whether the system meets its given
specifications
– To explore defects before the system is delivered
• Two main types of testing include
– Black box testing
– White box testing
Black box testing example
• Specification
– Write a program called TripleNumber to triple any
input integer
• The only testing you can do if you do not have
access to the code is to try some inputs
• Unfortunately, this may not find a fault in the
program
– All it proves is that it works correctly for these
values , at this time.
Specifying the inputs for test cases
• To improve the chance of finding defects, the
input for testing should cover
– Normal cases (should be general enough)
– Extreme/boundary/Validating cases
White box testing
• It is also called as structural testing
• Tests are derived from the knowledge of the
program code
• This knowledge allows the testing of the
various paths that the program execution can
take
Test Input Output
White box testing example
• Now we have access to the code
– In this case we can see that there is selection
controlled by whether the input is >= 1 or not
White box testing - test cases example
Case id Input Expected output Actual output Status 1 10 You are 10 year(s) old 2 -1 Invalid input 3 1 You are 1 year(s) old 4 twenty Invalid input Case 1 to cover the “if” path of the code. Case 2 to cover the “else” path of the code. Case 3 is the extreme/boundary case. Case 4 is the data validating case.
Calculator example
• Specification
– Write a program which takes a number, then
either invert it or take its square
– E.g., if the number is 5 it produces either 1/
(invert) or 25 (square)
Black box testing – invert test cases
Input Expected output Actual output Status 10 Invert result is 0.1 Invert result is 0.1 passed -10 Invert result is -0.1 Invert result is -0.1 passed 0 Cannot invert 0 Cannot invert 0 passed Twenty Invalid input Cannot invert 0 failed 9999999999999999 Invalid input Wrong unexpected result failed
Black box testing – square test cases Input Expected output Actual output Status 10 Square result is 100 Square result is 100 passed -10 Square result is 100 Square result is 100 passed 0 Square result is 0 Square result is 0 passed Twenty Invalid input Square result is 0 failed 9999999999999999 Invalid input Wrong unexpected output failed
Error handling in Calculator
• The black box testing also revealed that there
is some error handling in the code
• It recognized two standard errors for invert
– Trying to invert 0
– Trying to invert a text input
• It recognized one standard error for square
– Trying to square a text input
White box testing of the calculator