Module1 - Basics of Software Testing - Lecture Notes
Module1 - Basics of Software Testing - Lecture Notes
Lecture Notes
All of these applications need to run without any error and provide a quality service to the user of
the application. In this regard the software has to be tested for its accurate and correct working.
What is Software Engineering?
» Software testing is the process of executing the program with the intent of finding errors.
» Software testing is an important phase of SDLC which requires maximum effort in releasing
the software product to the market.
» Software testing ensures the Quality assurance of the Software product.
» Software testing is the process of conforming that the product/software has been
Manufactured/Developed
- According to Specification
- It is working properly
- It satisfies the customer
Error: People make errors (mistakes). In programming language, these mistakes are called as
bugs. Errors tend to propagate from a requirement error to design and then to coding.
Fault: a fault is the result of an error. It is the representation of error where representation is the
mode of expression such as text, dataflow diagram, and source code. There are two types of
faults:
A fault of commission- occurs when we enter something into a representation that is
incorrect.
A fault of omission- occurs when we fail to enter correct information.
Failure: Failure is the result of a faults execution. Represents the wrong behaviour of the system
Incident: Incident is the occurrence/symptoms that alert users or customers about a failure.
Test Case: It has an identity and is associated with program behaviour. They also have a set of
inputs and expected outputs.
“A mistake in coding is called error , error found by tester is called defect, defect accepted
by development team then it is called bug ,build does not meet the requirements then it Is
failure.”
Software Quality:
Quality software is reasonably bug or defect free, delivered on time and within budget, meets
requirements and/or expectations, and is maintainable.
Static quality attributes: Refers to the actual code and related documentation.
Static quality attributes include Structured, maintainable, testable code as well as the availability
of correct and complete documentation.
Dynamic quality attributes: Relate to the behavior of the application while in use.
Requirements
Requirement 1: It is required to write a program that inputs two integers and outputs the
maximum of these.
Requirement 2: It is required to write a program that inputs a sequence of integers and
outputs the sorted version of this sequence
Requirements: Incompleteness
Requirements: Ambiguity
Correctness
The ability of software products to perform their exact tasks, as defined by their
specification.
Show consistency between two Formalisms (e.g., specifications design, design to source
code, requirements to specifications, the "what" to the "how").
Reliability
Completeness
The Completeness refers to the availability of all features listed in the requirements, or in
the user manual.
An incomplete software is one that does not fully implement all features required.
Consistency refers to adherence to a common set of conventions and assumptions. For
example, all buttons in the user interface might follow a common color coding
convention.
Robustness Provides acceptable performance in the face of correctness or reliability failures
(e.g., graceful degradation). Concerned with behavior in face of unusual conditions.
Test case ID
Purpose
Preconditions
Inputs
Expected outputs
Post-conditions
Execution history
Date Result Version RunBy
Aim of Testing: Establishing the necessary preconditions, providing the test cases inputs,
observing the outputs, comparing these with the expected outputs, & then ensuring that the
expected post conditions exist to determine whether the test passed or failed.
Consider the relationships among the sets S,P & T. region 2 & 5 indicates the specified
behaviors that are not tested, region 1 & 4 shows specified behaviors that are tested, and region 3
& 7 represents the test cases that are correspond to unspecified behaviors.
Similarly, region 2 & 6 shows programmed behaviors that are not tested, region 1 & 3
shows the programmed behaviors that are tested & region 4 & 7 indicates test cases that
correspond to unprogrammed behaviors. Region 1 indicates the program being specified,
programmed & tested also. Testing is incomplete for all the regions means either of unspecified
behaviors or unspecified programs or unverified test cases. Region 1 is where the test cases are
identified by a testing method.
1. Functional Testing: It is based on the view that any program can be considered to be a
function that maps its input domain to values at its output range. The system is considered to
be a blackbox wherein the content (implementation or source code) of a black box is not known
& the function of the blackbox is understood completely in terms of its inputs & outputs.so it is
also called as Black Box Testing. It’s mainly concentrates on output generated for selected
inputs & execution condition. Here we design test cases based on the information from the
specification. Tester with a very little knowledge on the programming languages can do testing.
for Functional testing, Specification of the software is used.
Inputs Outputs
Disadvantages:
In the below figure, Method A identifies a larger set of test cases that does Method B. for
both methods, the set of test cases is completely contained within the set of specified behaviour.
Functional methods are based on the specified behavior, it is hard to imagine these methods
identifying behaviors that are not specified.
2. Structural Testing: It is a technique used in test case identification. It is also called as white
box (clear box) testing, wherein the implementation (of black box) is known & used to identify
test cases. The ability to ‘see inside’ the black box allows the tester to identify test cases based
on the function is actually implemented. The tester should have knowledge of linear graph theory
concepts eg: graphs, edges, nodes. Here the test coverage metrices are defined which provides a
way to explicitly state the extent to which software has been tested.
In the below figure, Method A identifies a larger set of test cases than Method B. All
behaviors are completely programmed as structural methods are based on programs. It is hard to
find the unprogrammed behaviors.
It uses only specifications to identify the test It uses program source code (implementation)
cases to identify the test cases
It is also called as Black Box Testing as It is also called as White Box Testing(Clear
implementation of the black box is not known box) wherein the implementation (of black
& it depends on only its inputs & outputs box) is known & used to identify test cases
Cosmetic
Call to non-existent
procedure
Data Faults
Incorrect initialization
Incorrect storage/access
Incorrect packing/unpacking
Incorrect subscript
Incorrect type
Off by one
Inconsistent data
A level of Testing describes the levels of abstraction found in the waterfall model of the
software development life cycle. The diagram represents the correspondence between testing and
design levels. In terms of functional testing, the three levels of definition (specification, preliminary
design, and detailed design) correspond directly to three levels of testing- system, integration, and
unit testing. The structural testing is appropriate at the unit level, while functional testing is more
appropriate at the system level.
Comments // text
Selection If<condition>
Case 1: <predicate>
<case clause>
………
Case n: <predicate>
<case clause>
EndCase
Simple version: The triangle program accepts three integers, a, b, and c, as input. These are taken to
be sides of a triangle. The output of the program is the type of triangle determined by the three sides:
Equilateral, Isosceles, Scalene, or Not A Triangle.
Improved version: “Simple version” plus better definition of inputs: The integers a, b, and c must
satisfy the following conditions:
c1. 1 ≤ a ≤ 200 c4. a < b + c
c2. 1 ≤ b ≤ 200 c5. b < a + c
c3. 1 ≤ c ≤ 200 c6. c < a + b
Final Version: “Improved version” plus better definition of outputs: If an input value fails any of
conditions c1, c2, or c3, the program notes this with an output message, for example, “Value of b is
not in the range of permitted values.” If values of a, b, and c satisfy conditions c1, c2, and c3, one of
four mutually exclusive outputs is given:
1. If all three sides are equal, the program output is Equilateral.
Pushpalatha K.S, Asst.Prof., ISE Dept., AIT, B’lore. Page 13
Software Testing (18IS62) 2023
Problems persist!
What output is expected for the input set (2, 2, 5)?
• Isosceles because a = b?
•NotATriangle because c > a+b?
Pseudocode
Program: Triangle1
int a,b,c,match
print "Enter 3 integers which are sides of a triangle”
read (a,b,c)
print "side a”
print "side b”
print "side c”
match=0;
If a==b //1
Then match=match+1; //2
EndIf
If a==c //3
Then match=match+2; //4
EndIf
If b==c //5
Then match=match+3; //6
EndIf
If match==0 //7
Then If (a+b)<=c //8
Then print "NotATriangle” //12.1
Else If (b+c)<=a //9
Then print "NotATriangle” //12.2
Else If (a+c)<=b //10
Then print "NotATriangle” //12.3
Else print "Scalene” //11
EndIf
EndIf
EndIf
Else If match=1 //13
Then If (a+c)<=b //14
Then print "NotATriangle” //12.4
Else print "isosceles" //15.1
EndIf
Else if match==2 //16
Then if(a+c)<=b //17
Then print "NotATriangle” //12.5
Else print "Isosceles” //15.2
EndIf
Else if match==3 //18
Then if (b+c)<=a //19
Flowchart
Program: Triangle2
int a,b,c,match
print "Enter 3 integers which are sides of a triangle”
read (a,b,c)
print "side a”
print "side b”
print "side c”
Program: Triangle3
int a,b,c
int c1,c2,c3, IaAtriangle
Do
print "Enter 3 integers which are sides of a triangle”
read (a,b,c)
c1=(1<=a) AND (a<=200)
c2=(1<=b) AND (b<=200)
c3=(1<=c) AND (c<=200)
if(!c1)
Then print “value of a is not in the range of permitted values”
EndIf
if(!c2)
Then print “value of b is not in the range of permitted values”
EndIf
if(!c3)
Then print “value of c is not in the range of permitted values”
EndIf
While (c1 && c2 && c3)
print "side a”
print "side b”
print "side c”
If IsATriangle
Then If (a==b) AND (b==c)
Then print "Equilateral"
Else If (a!=b) AND (b!=c) AND (c!=a)
Then print "Scalene”
Else print "Isosceles”
EndIf
EndIf
Else print “NotATriangle”
EndIf
//End Tringle3
Pseudocode:
Else
tmday=1;
tmmonth=month+1;
EndIf
case 12:
If day<31
Then tmday=day+1;
Else
tmday=1;
tmmonth=1;
If (year==2013)
Then print "input is invalid”
Else
tmyear =year+1;
EndIf
EndIf
case 2:
If day<28
then tmday=day+1;
Else
if(day==28)
Then If year%4=0
Then tmday=29 //leap year
Else
tmday=1;
tmmonth=3;
EndIf
Else If day=29
Then tmday=1;
tmmonth=3;
Else
Print "Feb can’t have 30 days:”
Endif
Endif
Endif
EndCase
Print "Next Date is tmmonth/tmday/tmyear”
End NextDate1
if(!c1)
Then print “day out of range”
EndIf
if(!c2)
Then print “month out of range”
EndIf
if(!c3)
Then print ”year out of range ”
EndIf
While (c1 && c2 && c3)
Switch (month)
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
If day<31
then tmday=day+1;
Else
tmday=1;
tmmonth=month+1;
EndIf
case 4:
case 6:
case 9:
case 11:
If day<30
then tmday=day+1;
Else
If day=30
tmday=1;
tmmonth=month+1;
Else
Print “Invalid Date input”
EndIf
EndIf
case 12:
If day<31
Then tmday=day+1;
Else
tmday=1;
tmmonth=1;
if(year==2013)
Then print "input is invalid”
Else
tmyear=year+1;
EndIf
EndIf
Pushpalatha K.S, Asst.Prof., ISE Dept., AIT, B’lore. Page 19
Software Testing (18IS62) 2023
case 2:
If day<28
then tmday=day+1;
Else
If day==28
Then If year%4=0
Then tmday=29 //leap year
Else
tmday=1;
tmmonth=3;
EndIf
Else
If day=29
Then If year%400=0
tmday=1;
tmmonth=3;
Else
If day>29
Then print "Feb can’t have 30 days:”
Endif
Endif
Endif
EndIf
EndIf
EndCase
Print "Next Date is tmmonth/tmday/tmyear”
End NextDate2
Problem Statement
A rifle salesperson in the former Arizona Territory sold rifle locks, stocks, and barrels made by a
gunsmith in Missouri. Locks cost $45, stocks cost $30, and barrels cost $25. The salesperson had to
sell at least one complete rifle per month, and production limits were such that the most the
salesperson could sell in a month was 70 locks, 80 stocks, and 90 barrels. After each town visit, the
salesperson sent a telegram to the Missouri gunsmith with the number of locks, stocks, and barrels
sold in that town. At the end of a month, the salesperson sent a very short telegram showing –1 locks
sold. The gunsmith then knew the sales for the month were complete and computed the salesperson’s
commission as follows: 10% on sales up to (and including) $1000, 15% on the next $800, and 20%
on any sales in excess of $1800. The commission program produced a monthly sales report that gave
the total number of locks, stocks, and barrels sold, the
salesperson’s total dollar sales, and, finally, the commission.
Pseudocode
program Commission
int locks,stocks,barrels
float lockprice,stockprice,barrelprice
int totallocks,totalstocks,totalbarrels
float locksales,stocksales,barrelsales,sales,commision
lockprice=45
stockprice=30
barrelprice=25
totallocks=0
totalstocks=0
totalbarrels=0
read (locks)
while (locks!=-1) //input devices uses -1 to indicate end of data
read (stocks, barrels)
totallocks=totallocks+locks
totalbarrels=totalbarrels+barrels
totalstocks=totalstocks+stocks
read (locks)
EndWhile
locksales=lockprice*totallocks
stocksales=stockprice*totalstocks
barrelsales=barrelprice*totalbarrels
sales=locksales+stocksales+barrelsales
print ("Total sales=",sales);
If(sales>1800.0)
Then
commision=0.10*1000
commision=commision+0.15*800.0
commision=commision+0.20*(sales-1800.0)
Else If (sales>1000.0)
Then
commision=0.10*1000
commision=commision+0.15*(sales-1000)
Else
commision=0.10*sales
EndIf
EndIf
Print ("commision is $",commision);
End Commission