21ISL66 - Software - Testing - Lab - Manual - Fina
21ISL66 - Software - Testing - Lab - Manual - Fina
1. Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of boundary value testing, derive
different test cases, execute these test cases and discuss the test results.
2. Design, develop, code and run the program in any suitable language to implement the
NextDate function. Analyze it from the perspective of equivalence class value testing,
derive different test cases, execute these test cases and discuss the test results.
3. Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of decision table-based testing,
derive different test cases, execute these test cases and discuss the test results.
4. Design and develop a program in a language of your choice to solve the triangle problem
defined as follows: Accept three integers which are supposed to be the three sides of a
triangle and determine if the three values represent an equilateral triangle, isosceles
triangle, scalene triangle, or they do not form a triangle at all. Assume that the upper limit
for the size of any side is 10. Derive test cases for your program based on boundary-value
analysis, equivalence class partitioning and decision-table approach and execute the test
cases and discuss the results.
5. Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of dataflow testing, derive different
test cases, execute these test cases and discuss the test results.
6. Design, develop, code and run the program in any suitable language to implement the
binary search algorithm. Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results.
Develop a Mini Project with documentation of suitable test-cases and their results to
perform automation testing of anyE-commerce or social media web page.
Suggested Guidelines:
● Create a WebDriver session.
● Navigate to a Web page.
● Locate the web elements on the navigated page.
● Perform an actions on the located elements.
● Assert the performed actions did the correct thing.
● Report the results of the assertions.
● End the session.
Each inputs / data feeds (ex: website, username, password, mobile no, product name,
etc.,) must be provided through a file linked with code and neither to be entered
manually nor to be included in the code
Use any software testing tool like selenium, Katalon, etc.,
1. Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of boundary value testing, derive
different test cases, execute these test cases and discuss the test results.
REQUIREMENTS SPECIFICATIONS:
• A rifle salesperson sold rifle locks, stocks, and barrels made by a gunsmith and the cost
are as follows:
Locks - $45
Stocks - $30
Barrels - $25
• The salesperson had to sell at least one complete rifle per month, and production limits
per month were 70 locks, 80 stocks, and 90 barrels.
• After each town visit, the salesperson has to send a telegram to the gunsmith with the
number of locks, stocks, and barrels sold in that town. At the end of the month, the
salesperson has to send a very short telegram showing -1 lock sold.
• The gunsmith then knew the sales for the month were complete and computed the
salesperson's commission as follows:
Sales from $1 to $1000 = 10%
Sales from $1001 to $1800 = 15%
Sales in excess of $1800 = 20%
The commission program produces a monthly sales report that gives the total number of
locks, stocks, and barrels sold, the salesperson's total dollar sales, and the commission.
ALGORITHM
totalLocks += locks;
totalStocks += stocks;
totalBarrels += barrels;
System.out.println("\nEnter -1 to end the sale, else enter the number of locks: ");
locks = scanner.nextInt();
}
if ((totalLocks >= 1 && totalLocks <= 70) && (totalStocks >= 1 && totalStocks <= 80) &&
(totalBarrels >= 1 && totalBarrels <= 90)) {
totalSales = (totalLocks * 45) + (totalStocks * 30) + (totalBarrels * 25);
if (totalSales <= 1000) {
commission = 0.10f * totalSales;
} else if (totalSales < 1800) {
commission = 0.10f * 1000;
commission += 0.15f * (totalSales - 1000);
} else {
commission = 0.10f * 1000;
commission += 0.15f * 800;
commission += 0.20f * (totalSales - 1800);
}
System.out.printf("The total sales is %d\nThe commission is %.2f\n", totalSales, commission);
} else {
System.out.println("\nInvalid Data\n");
}
scanner.close();
}
}
➢ Boundary value analysis focuses on the boundary of the input space to identify test cases.
The rationale behind boundary value testing is that errors tend to occur near the extreme
values of an input variable.
➢ The basic idea of boundary value analysis is to use input variable values at their minimum,
just above the minimum, a nominal value, just below their maximum, and their maximum.
➢ The boundary value analysis is based on a critical assumption; it is known as the single fault
assumption in reliability theory. This says that simultaneous occurrence of two (or more)
faults leads to failure.
➢ If we have a function of n variables, hold one variable value at the nominal and let the
remaining variable values as min, min+, nom, max-, and max values, repeating this for each
variable. Thus, for a function of n variables, boundary value analysis yields (4n + 1) unique
test cases.
Test Cases:
We can derive 13 test cases based on (4n+1) of BVA
Table 1.1: Commission Problem Boundary Value Analysis Test Cases
EXECUTIONS
Execute the program and test the test cases in above tables against program and complete the
table with for Actual output column and Status column.
TEST REPORT:
1. No of TC’s Executed: 13
2. No of Defects Raised: 0
3. No of TC’s Pass: 13
4. No of TC’s Failed: 0
Possible Viva Questions and answers
1. What is Boundary value analysis?
The values at the extremes (start/end values or lower/upper end values) of such class are
known as Boundary values. Analysing the behaviour of a system using such values is
called Boundary value analysis (BVA).
2. Faults found should be originally documented by whom?
By testers
3. Why does the boundary value analysis provide good test cases?
Boundary value analysis provides good test cases because of errors are frequently made during
programming of the different cases near the ‘edges’ of the range of values.
4. What makes an inspection different from other review types?
Inspection is led by a trained leader, uses formal entry and exit criteria, and checklists.
5. What is a V-Model?
V-Model is a software development model that illustrates, how testing activities integrates with
software development phases.
6. What is test coverage?
Test coverage is defined as a metric in Software Testing that measures the amount of testing
performed by a set of test.
7. What is called the process starting with the terminal modules?
Bottom-up integration
8. What is the purpose of test design technique?
Purpose of test design technique is to identify test conditions and test cases.
9. How many possible test cases can be generated , If the number of input
variables is n.
4n+1
10. What is Fault Masking?
Error condition hiding another error condition is called Fault Masking.
2. Design, develop, code and run the program in any suitable language to implement the
NextDate function. Analyse it from the perspective of equivalence class value testing,
derive different test cases, execute these test cases and discuss the test results.
REQUIREMENT SPECIFICATION
Problem Definition: "Next Date" is a function consisting of three variables like: month, date and
year. It returns the date of next day as output. It reads current date as input date.
The constraints are
C1: 1 ≤ month ≤ 12
C2: 1 ≤ day ≤ 31
C3: 1812 ≤ year ≤ 2012.
If condition C1 fails, then this function produces an output "value of month not in the range
1...12".
Since many combinations of dates not exist, hence we can simply display message for this
function: "Invalid Input Date".
A very common and popular problem occurs if the year is a leap year. We have taken into
consideration that there are 31 days in a month. But what happens if a month has 30 days or even
29 or 28 days?
A year is called as a leap year if it is divisible by 4, unless it is a century year. Century years are
leap years only if they are multiples of 400. So, 1992, 1996 and 2000 are leap years while 1900 is
not a leap year.
ALGORITHM
STEP11: if MM is 2
STEP12: if DD<28 do STEP4 else do STEP13
STEP13: if DD=28 & YYYY is a leap do STEP14 else STEP15
STEP14: tommorowday=29 goto STEP18
STEP15: tommorowday=1, tomorrowmonth=3, goto STEP18;
STEP16: if DD=29 then do STEP15 else STEP17
STEP17: output(“Cannot have feb”, DD); STEP19
STEP18: output(tomorrowday, tomorrowmonth, tomorrowyear);
STEP19: exit
PROGRAM
import java.util.Scanner;
public class NextDate {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int day, month, year;
int nextDay, nextMonth, nextYear;
return;
}
if (month == 2) {
if (((year % 4 == 0) && ((year % 100) != 0)) || ((year % 4 == 0) && (year % 100 == 0) && (year
% 400 == 0))) {
if (day == 29) {
System.out.println("next date is:");
nextMonth = month + 1;
nextDay = 1;
System.out.printf("%d-%d-%d\n", nextDay, nextMonth, year);
return;
} else if (day < 29) {
System.out.println("next date is:");
nextDay = day + 1;
System.out.printf("%d-%d-%d\n", nextDay, month, year);
return;
} else if (day > 29) {
System.out.printf("\nmonth %d does not have these number of days\n", month);
return;
}
} else {
if (day < 28) {
System.out.println("next date is:");
nextDay = day + 1;
System.out.printf("%d-%d-%d\n", nextDay, month, year);
return;
} else if (day == 28) {
System.out.println("next date is:");
nextDay = 1;
nextMonth = month + 1;
System.out.printf("%d-%d-%d\n", nextDay, nextMonth, year);
return;
} else if (day == 29) {
System.out.println("\ninvalid date: not a leap year\n");
return;
} else if (day > 28) {
System.out.printf("\nmonth %d does not have these number of days\n", month);
return;
}
}
}
return;
} else if ((day <= 31) && (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 ||
month == 10 || month == 12)) {
if (day < 31) {
System.out.println("next date is:");
nextDay = day + 1;
System.out.printf("%d-%d-%d\n", nextDay, month, year);
return;
} else if (day == 31 && month != 12) {
System.out.println("next date is:");
nextDay = 1;
nextMonth = month + 1;
System.out.printf("%d-%d-%d\n", nextDay, nextMonth, year);
return;
} else if (day == 31 && month == 12) {
System.out.println("next date is:");
nextMonth = 1;
nextDay = 1;
nextYear = year + 1;
System.out.printf("%d-%d-%d\n", nextDay, nextMonth, nextYear);
return;
} else {
System.out.printf("\nmonth %d does not have these number of days\n", month);
return;
}
}
}
}
TESTING
Test selection using equivalence partitioning allows a tester to subdivide the input domain into a
relatively small number of sub-domains, say N>1, as shown.
In strict mathematical terms, the sub-domains by definition are disjoint. The four subsets shown
in (a) constitute a partition of the input domain while the subsets in (b) are not. Each subset is
known as an equivalence class.
Test Case design
The NextDate function is a function which will take in a date as input and produces as output the
next date in the calendar. It uses three variables (month, day and year) where each have valid and
invalid intervals.
First Attempt
A first attempt at creating an equivalence relation might produce intervals such as :
Valid Intervals
M1 = {month: 1 ≤ month ≤ 12}
D1 = {day: 1 ≤day ≤31}
Y1 = {year: 1872 ≤ year ≤2012}
Invalid Intervals
M2 = {month: month < 1}
M3 = {month: month > 12}
D2 = {day: day < 1}
D3 = {day: day > 31}
Y2 = {year: year < 1872}
Y3 = {year: year > 2012}
At a first glance it seems that everything has been taken into account and our day, month and
year intervals have been defined well. Using these intervals we produce test cases using the four
different types of Equivalence Class testing.
Table 2.1: Weak and Strong Normal
TC Test Case Input Data Expected Actual
Status
Id Description DD MM YYYY Output Output
Testing for Valid
input changing the
1 15 6 1900 16-6-1900 16-6-1900 pass
day within the
month.
Since the number of variables is equal to the number of valid classes, only one weak normal
equivalence class test case occurs, which is the same as the strong normal equivalence class test
case (Table 2.1).
Table 2.2:Weak Robust
This is a table showing one corner of the cube in 3d-space (the three other corners would include
a different combination of variables) since the complete table would be too large to show.
EXECUTIONS
Execute the program and test the test cases in Table against program and complete the table with
for Actual output column and Status column.
Test Report:
1. No of TC’s Executed: 15
2. No of Defects Raised: 00
3. No of TC’s Pass: 15
4. No of TC’s Failed: 00
Possible Viva Questions and answers
1. What is equivalence class partitioning in testing?
Equivalence partitioning or equivalence class partitioning (ECP) is a
software testing technique that divides the input data of a software unit
into partitions of equivalent data from which test cases can be derived.
2. What is Weak Normal Equivalence Class Testing?
Identify equivalence classes of valid values is the Weak Normal Equivalence Class
Testing.
3. What will be the next date if input is 28-2-1900?
1-3-1900
4. What will be the next date if the input is 31-6-2000?
Month 6 does not have 31 days.
5. How many test cases will be generated if corresponding to variable1, four
equivalence classes, variable2 has 4 classes, and variable3 has 2 equivalence
classes?
4*4*2=32 test cases can be generated.
6. What is the main benefit of designing tests early in the life cycle?
It helps to prevent defects from being introduced into the code.
7.What is a defect in software testing?
Defect is any variance between actual and expected results. “A mistake in coding is called
Error, error found by tester is called Defect.
8. What is white box testing and list the types of white box testing?
White box testing technique involves selection of test cases based on an analysis
of the internal structure (Code coverage, branches coverage, paths coverage,
condition coverage, etc.) of a component or system.
9. What are the different black box testing techniques?
Equivalence Partitioning, Boundary value analysis and Decision-Table testing
10. What is the difference between static and dynamic testing?
Static testing: During Static testing method, the code is not executed, and it is performed
using the software documentation.
Dynamic testing: To perform this testing the code is required to be in an executable form
3. Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of decision table-based testing,
derive different test cases, execute these test cases and discuss the test results.
REQUIREMENTS SPECIFICATIONS:
R1: The system should read the number of Locks, Stocks and Barrels sold in a month.
(1≤ Locks≤ 70)
(1 ≤ Stocks ≤ 80)
(1 ≤ Barrels ≤ 90)
R2: If R1 is satisfied the system should compute the salesperson’s commission depending on
the total number of Locks, Stocks & Barrels sold else it should display suitable error
message.
Following is the percentage of commission for the sales done:
o 10% on sales up to (and including) $1000
o 15% on next $800
o 20% on any sales in excess of $1800
The system should compute the total dollar sales and output salespersons total dollar sales,
and his commission.
ALGORITHM
{
commission = 0.10 * 1000;
commission = commission + (0.15 * (total_sales - 1000));
}
else
{
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (total_sales - 1800));
}
Step 6: Output (“Commission is $”, Commission)
Step 7: Exit
PROGRAM
import java.util.Scanner;
public class SalesCommission {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int locks, stocks, barrels, totalLocks = 0, totalStocks = 0, totalBarrels = 0;
int totalSales;
double commission = 0.0;
System.out.print("Enter the number of locks: ");
locks = scanner.nextInt();
while (locks != -1) {
System.out.print("Enter the number of stocks: ");
stocks = scanner.nextInt();
System.out.print("Enter the number of barrels: ");
barrels = scanner.nextInt();
totalLocks += locks;
totalStocks += stocks;
totalBarrels += barrels;
System.out.println("\nEnter -1 to end the sale, else enter the number of locks: ");
locks = scanner.nextInt();
}
if ((totalLocks >= 0 && totalLocks <= 70) && (totalStocks >= 0 && totalStocks <= 80)
&& (totalBarrels >= 0 && totalBarrels <= 90)) {
totalSales = (totalLocks * 45) + (totalStocks * 30) + (totalBarrels * 25);
Conditions R1 R2 R3 R4 R5 R6
C1: 1≤locks≤70? F T T T T T
C2: 1≤stocks≤80? -- F T T T T
C3: 1≤barrels≤90? -- -- F T T T
C4: sales>1800? -- -- -- T F F
C5: sales>1000? -- -- -- -- T F
C6: sales≤1000? -- -- -- -- -- T
Rule Count 32 16 08 04 02 01
a1: com1 = 0.10*Sales X
a2: com2 = com1+0.15*(sales-1000) X
a3: com3 = com2+0.20*(sales-1800) X
a4: Out of Range. X X X
Using the decision table we get 6 functional test cases: 3 cases out of range, 1 case each for sales
greater than $1800, sales greater than $1000, sales less than or equal to $1000.
Table 3.2: Deriving test cases using Decision table:
TC Test Case Expected Actual
Locks Stocks Barrels Status
ID Description Output Output
Testing for
1 Requirement 1 -2 40 45 Invalid Data Invalid Data Pass
Condition 1 (C1)
Testing for
2 Requirement 1 90 40 45 Invalid Data Invalid Data Pass
Condition 1 (C1)
Testing for
3 Requirement 1 35 -3 45 Invalid Data Invalid Data Pass
Condition 2 (C2)
Testing for
4 Requirement 1 35 100 45 Invalid Data Invalid Data Pass
Condition 2 (C2)
Testing for
5 Requirement 1 35 40 -10 Invalid Data Invalid Data Pass
Condition 3 (C3)
Testing for
6 Requirement 1 35 40 150 Invalid Data Invalid Data Pass
Condition 3 (C3)
Testing for a1:5
7 5 5 5 500 50 Pass
Requirement 2 0
Testing for a2:
8 15 15 15 1500 175 Pass
Requirement 2 175
Testing for a3:
9 25 25 25 2500 360 Pass
Requirement 2 360
TEST REPORT:
1. No of TC’s Executed: 09
2. No of Defects Raised: 00
3. No of TC’s Pass: 09
4. No of TC’s Failed: 00
The commission problem is not well served by a decision table analysis because it has very little
decisional. Because the variables in the are truly independent, no impossible rules will occur in a
decision table in which condition correspond to the equivalence classes.
4. Design and develop a program in a language of your choice to solve the triangle problem
defined as follows: Accept three integers which are supposed to be the three sides of a
triangle and determine if the three values represent an equilateral triangle, isosceles triangle,
scalene triangle, or they do not form a triangle at all. Assume that the upper limit for the size
of any side is 10. Derive test cases for your program based on boundary-value analysis,
equivalence class partitioning and decision-table approach and execute the test cases and
discuss the results.
REQUIREMENTS SPECIFICATION:
R1: The program should accept 3 integer values a, b & c which represent the 3 sides of a triangle
R2: If the R1 satisfies, based on the input, program should determine whether triangle can be
formed or not
R3: If R1 & R2 holds good, then the program should determine the type of triangle i.e.,
Equilateral (Three sides are equal)
Isosceles (Two sides are equal)
Scalene (Three sides are unequal)
Else report suitable error message
R4. Upper Limit for the size of any side is 10
ALGORITHM
Step 1: Get input a, b and c i.e., 3 integers which are sides of a triangle
Step 2: Is sides of a triangle are within the boundary?
If a>0 AND a<10AND b>0AND b<10AND c>0 AND c<10
Then flag=1
Else flag=0
EndIf
Step 3: If flag=1
Is a triangle?
If (a < (b + c)) AND (b < (a + c)) AND (c < (a + b))
Then IsATriangle = True
Else IsATriangle = False
EndIf
EndIf
if (((a >= 1) && (a <= 10)) && ((b >= 1) && (b <= 10)) && ((c >= 1) &&
(c <= 10))) {
if ((a < (b + c)) && (b < (a + c)) && (c < (a + b))) {
System.out.println("The triangle construction is possible");
if (a == b && b == c) {
System.out.println("The triangle is Equilateral");
} else if (a == b || b == c || a == c) {
System.out.println("The triangle is isosceles");
} else {
System.out.println("The triangle is scalene");
}
} else {
System.out.println("The triangle construction is not possible");
}
}
}
}
TESTING
Technique: Boundary value analysis
➢ Boundary value analysis focuses on the boundary of the input space to identify test cases.
The rationale behind boundary value testing is that errors tend to occur near the extreme
values of an input variable.
➢ The basic idea of boundary value analysis is to use input variable values at their
minimum, just above the minimum, a nominal value, just below their maximum, and
their maximum.
➢ The boundary value analysis is based on a critical assumption; it is known as the single
fault assumption in reliability theory. This says that failures are only rarely the result of
the simultaneous occurrence of two (or more) faults.
➢ If we have a function of n variables, hold one variable value at the nominal and let the
remaining variable values as min, min+, nom, max-, and max values, repeating this for
each variable. Thus, for a function of n variables, boundary value analysis yields (4n + 1)
unique test cases.
Test Cases:
We can derive 13 test cases based on (4n+1) of BVA
Table 4.1 Triangle Problem Boundary Value Analysis Test Cases
TC Input Expected
Test Case Description Actual Output Status
ID a b c Output
The triangle is The triangle is
01 Testing for 1, 1, 1 1 1 1 Pass
Equilateral Equilateral
The triangle The triangle
02 Testing for 1, 1, 2 1 1 2 construction is not construction is not Pass
possible possible
The triangle The triangle
03 Testing for 1, 1, 5 1 1 5 construction is not construction is not Pass
possible possible
The triangle The triangle
04 Testing for 1, 1, 9 1 1 9 Pass
construction is not construction is not
possible possible
TESTING
Technique: Equivalence Class Testing
The use of equivalence classes for functional testing has two motivations:
✓ To have a sense of complete testing
✓ Hope to avoid redundancy.
The important aspect of equivalence classes is that they form a partition of a set, where partition
refers to a collection of mutually disjoint subsets, the union of which is the entire set. Here entire
set provides a form of completeness, and the disjointedness ensures a form of non-redundancy.
The idea of equivalence class testing is to identify test cases by using one element from each
equivalence class. If the equivalence classes are chosen wisely, this greatly reduces the potential
redundancy among test cases.
Equivalence Class Test Cases for the Triangle Problem
✓ The maximum limit of each side a, b & c of the triangle is 10 units according to
requirement R4.
0 ≤ a ≤ 10
0 ≤ b ≤ 10
0 ≤ c ≤ 10
✓ In the problem statement, note that four possible outputs can occur: Not a Triangle,
Scalene, Isosceles and Equilateral.
We can use these to identify output (range) equivalence classes as follows:
R1 = {<a, b, c>: the triangle with sides a, b, and c is equilateral}
R2 = {<a, b, c>: the triangle with sides a, b, and c is isosceles}
R3 = {<a, b, c>: the triangle with sides a, b, and c is scalene}
R4 = {<a, b, c>: sides a, b, and c do not form a triangle}
Table 4.4: Weak Normal Equivalence Class Test Cases
Input
TC Test Case Expected Actual
Status
ID Description a b c Output Output
The triangle is The triangle is
1 WN1 5 5 5 Pass
Equilateral Equilateral
The triangle is The triangle is
2 WN2 2 2 3 Pass
isosceles isosceles
The triangle is The triangle is
3 WN3 3 4 5 Pass
Scalene Scalene
TESTING
Technique: Decision Table-Based Testing
Decision tables have been used to represent and analyze complex logical relationship since the
early 1960s. Decision table consists of four areas such as,
A decision table has four portions:
1. Leftmost column is the Stub portion
2. Right columns of stub is the Entry portion
3. The Condition portion is noted by c’s
4. The Action portion is noted by a’s
• Rules indicates which action are taken for the circumstance indicated in the condition portion
of the rule
• The don’t care entries are denoted by “ -- ” or “ n/a ” and it means “ must be false” or “ the
condition is irrelevant ”
• If conditions are allowed to have binary values (true/false, yes/no, 0/1) in the decision table are
called limited entry decision tables.
• If conditions are allowed to have several values, the resulting tables are called extended entry
decision tables.
Program:
import java.util.Scanner;
import java.lang.Math;
int a, b, c;
int flag = -1;
Scanner scanner = new Scanner(System.in);
if ((a >= 0 && a <= 10) && (b >= 0 && b <= 10) && (c >= 0 && c <= 10)) {
// Triangle Inequality Theorem: every side's length should be shorter than
sum of other two sides
if (((a + b) > c) && ((b + c) > a) && ((c + a) > b)) {
flag = 1;
if ((a == b) && (b == c))
System.out.println("It is an Equilateral Triangle");
else if ((a == b) || (b == c) || (c == a))
System.out.println("It is an Isosceles Triangle");
else
System.out.println("It is a Scalene Triangle");
}
}
if (flag == -1)
System.out.println("Given side inputs cannot form a triangle");
scanner.close();
}
Table 4.7: Decision Table for the Triangle Problem
Condition & Rules
Actions R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11
c1: a< b + c? F T T T T T T T T T T
c2: b< a + c? - F T T T T T T T T T
c3: c< a + b? - - F T T T T T T T T
c4: a = b? - - - T T T T F F F F
c5: a = c? - - - T T F F T T F F
c6: b =c? - - - T F T F T F T F
Rule Count 32 16 8 1 1 1 1 1 1 1 1
a1: Not a Triangle X X X
a2: Scalene X
a3: Isosceles X X X
a4: Equilateral X
a5: Impossible X X X
possible possible
The triangle The triangle
Testing for construction construction
03 3 2 7 Pass
Not a Triangle is not is not
possible possible
Testing for The triangle The triangle
04 8 8 8 Pass
Equilateral is Equilateral is Equilateral
Testing for
05 ? ? ? Impossible Impossible Pass
impossible
Testing for
06 ? ? ? Impossible Impossible Pass
impossible
Testing for The triangle The triangle
07 6 6 7 Pass
Isosceles is Isosceles is Isosceles
Testing for
08 ? ? ? Impossible Impossible Pass
impossible
Testing for The triangle The triangle
09 6 7 6 Pass
Isosceles is Isosceles is Isosceles
Testing for The triangle The triangle
10 7 6 6 Pass
Isosceles is Isosceles is Isosceles
Testing for The triangle The triangle
11 3 4 5 Pass
Scalene is Scalene is Scalene
EXECUTIONS
Execute the program and test the test cases in above tables against program and complete the
table with for Actual output column and Status column
TEST REPORT:
1. No of TC’s Executed: 85
2. No of Defects Raised: 0
3. No of TC’s Pass: 85
4. No of TC’s Failed: 0
Possible Viva Questions and answers
1. What is the Software Testing?
A process of analyzing a software item to detect the differences between existing and required
conditions (i.e., defects) and to evaluate the features of the software item.
2. What is Boundary Testing?
Test which focus on the boundary or limit conditions of the software being tested.
3. What is Bug?
A software bug is an error, flaw or fault in a computer program or system that causes it to produce
an incorrect or unexpected result, or to behave in unintended ways.
4. What is Defect?
A defect is an error or a bug, in the application which is created.
5. How many possible test cases can be generated, If the number of inputs
variables is n.
4n+1
6. What is Debugging?
Debugging is the process of finding and resolving defects or problems within a computer program
7. How many types of testing?
There are two types of testing-
1. Functional- Black Box Testing
2. Structural- white Box Testing.
8. What is the Test Case?
A test case is a document, which has a set of test data, preconditions, expected results and post
conditions, developed for a particular test scenario in order to verify compliance against a specific
requirement.
9. Define static testing.
Static testing is a method of checking documents and files.
10. Define dynamic testing.
Dynamic testing is a process of testing the real product.
5. Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of dataflow testing, derive different
test cases, execute these test cases and discuss the test results.
REQUIREMENTS SPECIFICATIONS:
A rifle salesperson sold rifle locks, stocks, and barrels made by a gunsmith and the cost are as
follows:
✓ Locks - $45
✓ Stocks - $30
✓ Barrels - $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 has to send a telegram to the gunsmith as number of locks,
stocks, and barrels sold in that town. At the end of a month, the salesperson has to send a very
short telegram showing -1 lock sold.
The gunsmith then knew the sales for the month were complete and computed the salesperson's
commission as follows:
✓ Sales from $1 to $1000 = 10%
✓ Sales from $1001 to $1800 = 15%
✓ Sales in excess of $1800 = 20%
The commission program produces a monthly sales report that gave the total number of locks,
stocks, and barrels sold, the salesperson's total dollar sales, and the commission.
ALGORITHM
PROGRAM
import java.util.Scanner;
totalLocks += locks;
totalStocks += stocks;
totalBarrels += barrels;
System.out.println("\nEnter -1 to end the sale, else enter the number of locks: ");
locks = scanner.nextInt();
}
if ((totalLocks >= 0 && totalLocks <= 70) && (totalStocks >= 0 && totalStocks <=
80) && (totalBarrels >= 0 && totalBarrels <= 90)) {
totalSales = (totalLocks * 45) + (totalStocks * 30) + (totalBarrels * 25);
scanner.close();
}
}
TESTING
Dataflow testing refers to forms of structural testing that focus on the points at which variables
receive values and the points at which these values are used (or referenced).
USE(v, n): Node n ϵ G(P) is a usage node of the variable v ϵ V, written as USE(v, n), iff the
value of the variable v is used at the statement fragment corresponding to node n.
P-use and C-use: A usage node USE(v, n) is a predicate use (P-use) iff the statement n is a
predicate statement; otherwise, USE(v, n) is a computation use (C-use)
The nodes corresponding to predicate uses always have an outdegree ≥ 2, and nodes
corresponding to computation uses always have an outdegree ≥1.
du-path: A definition-use path with respect to a variable v (du-path) is a path in PATHS(P) such
that for some v ϵ V, there are define and usage nodes DEF(v, m) and USE(v, n) such that m and n
are the initial and final nodes of the path.
22 →23
22 →24
22 →26
total_sales
22 →28
22 →33
22 →35
Selected Pairs
commission 24 →35
28 →35
33 →35
Test Cases Based on All Definitions: To achieve 100% All-definitions data flow coverage at
least one sub-path from each variable definition to some use of that definition (either c- or p-
use) must be executed.
Test Cases:
Table 9.3: Commission problem data flow test cases
Actual
Inputs Expected output Status
Output
Tc Variable lock stoc barrel total_sale Commi Commi
du-pair sub-path
ID (s) s ks s s -ssion -ssion
1 locks 8 →9 8 →9 35 - - - - - Pass
3 19 →9 19 →9 -1 40 45 Invalid Pass
total_sale Pass
7 22 →23 22 →23 5 5 5 500 50 50
s
8 22 →24 22, 23, 24 5 5 5 500 50 50 Pass
EXECUTION
Execute the program and test the test cases in above Tables against program and complete the
table with for Actual output column and Status column
Test Report:
1. No of TC’s Executed: 15
2. No of Defects Raised: 00
3. No of TC’s Pass: 15
4. No of TC’s Failed: 00
Cost of Stocks=$30
Cost of Barrels=$45
9. How commission is calculated for the sales?
If sales<1000 then 10% commission
If 1000>sales<1800 then
Commission=1000*10%
Commission=Commission+(sales-1000)*15%
If sales>1800 then
commission = 10% * 1000;
commission = commission + 15% * 800
commission = commission + (20%* sales - 1800)
10. Define data flow.
Data Flow: – Base the coverage criterion on how variables are defined and used
in the program.
6. Design, develop, code and run the program in any suitable language to implement the
binary search algorithm. Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results
REQUIREMENTS
R1: The system should accept ‘n’ number of elements and key element that is to be searched
among ‘n’ elements..
R2: Check if the key element is present in the array and display the position if present
otherwise print unsuccessful search.
ALGORITHM
Step 1: Input value of ‘n’. Enter ‘n’ integer numbers in array int mid;
Step 2: Initialize low = 0, high = n -1
Step 3: until ( low <= high ) do
mid = (low + high) / 2
if ( a[mid] == key )
then do Step 5
else if ( a[mid] > key )
then do
high = mid - 1
else
low = mid + 1
Step 4: Print unsuccessful search do step 6.
Step 5: Print Successful search. Element found at position mid+1.
Step 6: Stop.
PROGRAM
import java.util.Scanner;
array[i] = scanner.nextInt();
}
low = 0;
high = n - 1;
TESTING
Technique Used: Basis Path Testing
Basis path testing is a form of Structural testing (White Box testing). The method devised by
McCabe to carry out basis path testing has four steps. These are:
1. Compute the program graph.
2. Calculate the cyclomatic complexity.
3. Select a basis set of paths.
4. Generate test cases for each of these paths.
Step 1: The program graph and DD-path graph for binary search program is shown below
Using the program graph, DD (Decision-to-Decision) path graph is derived for binary search
program
Fig 6.2: DD- Path Graph for Binary Search Program
V(G) = e - n + p or V(G) = e - n + 2p
Step 3: The six linearly independent paths of our graph are as follows:
Test Report:
1. No of TC’s Executed: 06
2. No of Defects Raised: 00
3. No of TC’s Pass: 06
4. No of TC’s Failed: 00
Possible Viva Questions and answers