0% found this document useful (0 votes)
189 views51 pages

21ISL66 - Software - Testing - Lab - Manual - Fina

software testing

Uploaded by

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

21ISL66 - Software - Testing - Lab - Manual - Fina

software testing

Uploaded by

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

SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

SOFTWARE TESTING LABORATORY


Subject Code 21ISL66 IA Marks 50
Teaching Hours/Week(L:T:P:S): 0:0:2:0 Exam Marks 50
Total Number of Lecture Hours 24 Exam Hours 03

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.

PART B – Practical Based Learning

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 1


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.,

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 2


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Step 1: Define locks_price = 45$, stock_price= 30$, barrel_price = 25$


Step 2: Input (locks)
Step 3: while (locks !=-1) ‘Input device uses -1 to indicate end of data’
Input (stocks, barrels)
calculate total_locks, total_stocks, total_barrels
Input (locks)
End while
Step 4: calculate total sales
total_sales = (total_locks *45) + ( total_stocks*30) + (total_barrels * 25)
Step 5: if (total_sales <= 1000)

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 3


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

commission = 0.10 * total_sales;


else if (total_sales < 1800)
{
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, totalSales;
int totalLocks = 0, totalStocks = 0, totalBarrels = 0;
float commission = 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;

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 4


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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();
}
}

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 5


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

➢ 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

TC Test Case Input Expected Output Actual Output Status


ID Description Locks Stocks Barrels Sales Commission (Commission)
01 Testing for
35 40 1 2800 420 420 Pass
35, 40, 1
02 Testing for
35 40 2 2825 425 425 Pass
35, 40, 2
03 Testing for
35 40 45 3900 640 640 Pass
35, 40, 45
04 Testing for
35 40 89 5000 860 860 Pass
35, 40, 89
05 Testing for
35 40 90 5025 865 865 Pass
35, 40, 90
06 Testing for
35 1 45 2730 406 406 Pass
35, 1, 45
07 Testing for
35 2 45 2760 412 412 Pass
35, 2, 45
08 Testing for
35 79 45 5070 874 874 Pass
35, 79, 45
09 Testing for
35 80 45 5100 880 880 Pass
35, 80, 45
10 Testing for
1 40 45 2370 334 334 Pass
1, 40, 45
11 Testing for
2 40 45 2415 343 343 Pass
2, 40, 45
12 Testing for
69 40 45 5430 940 940 Pass
69, 40, 45
13 Testing for
70 40 45 5475 955 955 Pass
70, 40, 45

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 6


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 7


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

STEP 1: Input date in format DD.MM.YYYY


STEP2: if MM is 01, 03, 05,07,08,10 do STEP3 else STEP6
STEP3:if DD < 31 then do STEP4 else if DD=31 do STEP5 else output(Invalid Date);
STEP4: tomorrowday=DD+1 goto STEP18
STEP5: tomorrowday=1; tomorrowmonth=month + 1 goto STEP18
STEP6: if MM is 04, 06, 09, 11 do STEP7
STEP7: if DD<30 then do STEP4 else if DD=30 do STEP5 else output(Invalid Date);
STEP8: if MM is 12
STEP9: if DD<31 then STEP4 else STEP10
STEP10: tomorrowday=1, tommorowmonth=1, tommorowyear=YYYY+1;
goto STEP18

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 8


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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;

System.out.print("\nEnter the date in format DD MM YYYY: ");


day = scanner.nextInt();
month = scanner.nextInt();
year = scanner.nextInt();

if (day < 1 || day > 31) {


System.out.println("\ninvalid day\n");
return;
}
if (month < 1 || month > 12) {
System.out.println("\ninvalid month\n");
return;
}
if (year < 1872 || year > 2012) {
System.out.println("\ninvalid year\n");

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 9


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

return;
}

if (month == 4 || month == 6 || month == 9 || month == 11) {


if (day > 30) {
System.out.println("\ninvalid day\n");
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);

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 10


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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;
}
}
}

if ((day <= 30) && (month == 4 || month == 6 || month == 9 || month == 11)) {


if (day < 30) {
System.out.println("next date is:");
nextDay = day + 1;
System.out.printf("%d-%d-%d\n", nextDay, month, year);
return;
} else if (day == 30) {
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 && year == 2012)) {
System.out.println("Value of the year crossed its boundary\n:");

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 11


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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;
}
}
}
}

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 12


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

TESTING

Technique used: Equivalence Class 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}

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 13


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

TC Input Data Expected Actual


Test Case Description Status
Id DD MM YYYY Output Output
Testing for Valid input
1 changing the day within 15 6 1900 16-6-1900 16-6-1900 Pass
the month.
Testing for Invalid Day,
2 day with negative -1 6 1900 Invalid day Invalid day Pass
number it is not possible
Testing for Invalid Day,
3 day with Out of range 32 6 1900 Invalid day Invalid day Pass
i.e., DD=32
Testing for Invalid
Month, month with
4 15 -1 1900 Invalid month Invalid month Pass
negative number it is not
possible
Testing for Invalid
month, month with out
5 13 13 1900 Invalid month Invalid month Pass
of range i.e., MM=13 it
should MM<=12
Testing for Year, year is
out of range
6 6 11 1802 Invalid year Invalid year Pass
YYYY=1862, it should
>=1812
Testing for Year, year is
out of range
7 6 11 2013 Invalid year Invalid year Pass
YYYY=2013, it should
<=2012
We see that the weak robust equivalence class testing will just test the ranges of the input
domain once on each class. Since we are testing weak and not normal, there will be only one
fault per test case (single fault assumption) unlike Strong Robust Equivalence class testing.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 14


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

Table 2.3: Strong Robust:

Input Data Expected


TC Id Test Case Description Actual Output Status
DD MM YYYY Output
Testing for Month is not
in range MM=-1 i.e., in
negative number there is
1 15 -1 1900 Invalid month Invalid month Pass
not possible have to be
month in negative
number
Testing for Day is not in
range DD=-1 i.e., in
2 negative number there is -1 6 1900 Invalid day Invalid day Pass
not possible have to be
Day in negative number
Testing for Year is not in
3 range YYYY=1869 i.e., 6 15 1809 Invalid Year Invalid Year Pass
Year should >=1812
Testing for Day and
month is not in range
MM=-1, DD=-1 i.e., in Invalid day Invalid day
4 negative number there is -1 -1 1900 Invalid month Invalid month Pass
not possible have to be
Day and Month in
negative number
i) Testing for Day is not
in range and Year is not
in range DD=-1 i.e., in
negative number there is
Invalid day Invalid day
not possible have to be
5 -1 6 1811 Invalid year Invalid year Pass
Day in negative number,
and
ii) YYYY=1811, so the
range of year is not
>=1812
i) Testing for Month is
not in range MM=-1 and
i.e., in negative number
there is not possible have Invalid month Invalid month
6 to be Day in negative 6 -1 1811 Invalid year Invalid year Pass
number, and
ii) Year is not in range
YYYY=1899, year
should >=1812
i) Testing for Day is not
in range DD=-1 i.e., in
negative number there is
not possible have to be
Day in negative number
ii) Testing for Month is Invalid day Invalid day
not in range MM=-1 and Invalid month Invalid month
7 -1 -1 1811 Pass
i.e., in negative number Invalid year Invalid year
there is not possible have
to be Day in negative
number, and
iii) Year is not in range
YYYY=1869, year
should >=1812

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 15


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 16


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 17


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Step 1: Define locks_price = 45 $, stock_price= 30$, barrelprice = 25 $


Step 2: Input (locks)
Step 3: while (locks !=-1) ‘Input device uses -1 to indicate end of data’
Input (stocks, barrels)
calculate total_locks, total_stocks, total_barrels
Input (locks)
End while
Step 4: calculate total sales
total_sales = (total_locks *45) + ( total_stocks*30) + (total_barrels * 25)
Step 5: if (total_sales <= 1000)
commission = 0.10 * total_sales;
else if (total_sales < 1800)

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 18


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

{
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;

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 19


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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);

if (totalSales <= 1000) {


commission = 0.10 * totalSales;
} else if (totalSales < 1800) {
commission = 0.10 * 1000;
commission += 0.15 * (totalSales - 1000);
} else {
commission = 0.10 * 1000;
commission += 0.15 * 800;
commission += 0.20 * (totalSales - 1800);
}
System.out.println("The total sales is " + totalSales);
System.out.println("The commission is " + commission);
} else {
System.out.println("\nInvalid Data");
}
scanner.close();
}
}

TESTING TECHNIQUE: Decision Table-Based Testing


Table 3.1 Decision Table for the Commission Problem

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 20


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

EXECUTION & RESULT DISCUSION:


Execute the program against the designed test cases and complete the table for Actual output
column and status column.

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 21


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Possible Viva Questions and answers

1. What is Test Suite?


Test Suite is a collection of test cases. The test cases which are intended to test an application.
2. What is Test Scenario?
Test Scenario gives the idea of what we have to test. Test Scenario is like a high-level test
case.
3. What is Test Data?
Test data is the data that is used by the testers to run the test cases.
4. What is Test Harness?
A test harness is the collection of software and test data configured to test a program unit by
running it under varying conditions which involves monitoring the output with expected
output.
5. What is test coverage?
Test coverage helps in measuring the amount of testing performed by a set of tests.
6. What is Alpha Testing?
Alpha testing is done by the in-house developers (who developed the software) and testers.
Sometimes alpha testing is done by the client or outsourcing team with the presence of
developers or testers.
7. What is Gamma Testing?
Gamma testing is done when the software is ready for release with specified requirements.
8. In the limited entry Decision table, how many rules can be generates if the
number of conditions is n?
There are 2n number of rules can be generated.
9. What is the purpose of decision tables?
The purpose of a decision table is to show a logical structure, with all possible combinations
of conditions and resulting actions.
10. What is Formal Testing?
It is a process where the testers test the application by having pre-planned procedures and
proper documentation.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 22


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 23


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

Step 4: Determine Triangle Type


If IsATriangle
Then If (a = b) AND (b = c)
Then triangle is an equilateral
Else If (a ≠ b) AND (a ≠ c) AND (b ≠ c)
Then triangle is a Scalene
Else triangle is an Isosceles
EndIf
EndIf
Else "Not a Triangle"
EndIf
Step 5: If flag=0
Sides of the triangle are out of boundary.
End triangle
PROGRAM
import java.util.Scanner;
public class TriangleChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter three sides a, b & c of a triangle");
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
if ((a < 1) || (a > 10)) {
System.out.println("Value of a is not in the range of permitted values");
}
if ((b < 1) || (b > 10)) {
System.out.println("Value of b is not in the range of permitted values");
}
if ((c < 1) || (c > 10)) {
System.out.println("Value of c is not in the range of permitted values");
}

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 24


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 25


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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 Actual


Test Case Description Status
ID a b c Output Output
The triangle is The triangle is
01 Testing for 1, 5, 5 1 5 5 Pass
Isosceles Isosceles
The triangle is The triangle is
02 Testing for 2, 5, 5 2 5 5 Pass
Isosceles Isosceles
The triangle is The triangle is
03 Testing for 5, 5, 5 5 5 5 Pass
Equilateral Equilateral
The triangle is The triangle is
04 Testing for 9, 5, 5 9 5 5 Pass
Isosceles Isosceles
The triangle The triangle
05 Testing for 10, 5, 5 10 5 5 construction is not construction is Pass
possible not possible
The triangle is The triangle is
06 Testing for 5, 1, 5 5 1 5 Pass
Isosceles Isosceles
The triangle is The triangle is
07 Testing for 5, 2, 5 5 2 5 Pass
Isosceles Isosceles
The triangle is The triangle is
08 Testing for 5, 9, 5 5 9 5 Pass
Isosceles Isosceles
The triangle The triangle
09 Testing for 5, 10, 5 5 10 5 construction is not construction is Pass
possible not possible
The triangle is The triangle is
10 Testing for 5, 5, 1 5 5 1 Pass
Isosceles Isosceles
The triangle is The triangle is
11 Testing for 5, 5, 2 5 5 2 Pass
Isosceles Isosceles
The triangle is The triangle is
12 Testing for 5, 5, 9 5 5 9 Pass
Isosceles Isosceles
The triangle The triangle
13 Testing for 5, 5, 10 5 5 10 construction is not construction is Pass
possible not possible

Table 4.2 Triangle Problem Robustness Test Cases

TC Test Case Input Expected Actual


Status
ID Description a b c Output Output
The triangle The triangle
01 Testing for 5, 5, -1 5 5 -1 construction is construction is not Pass
not possible possible
The triangle is The triangle is
02 Testing for 5, 5, 1 5 5 1 Pass
Isosceles Isosceles
The triangle is The triangle is
03 Testing for 5, 5, 1 5 5 2 Pass
Isosceles Isosceles
The triangle is The triangle is
04 Testing for 5, 5, 5 5 5 5 Pass
Equilateral Equilateral
The triangle is The triangle is
05 Testing for 5, 5, 9 5 5 9 Pass
Isosceles Isosceles

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 26


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

The triangle is The triangle is


06 Testing for 5, 5, 10 5 5 10 Pass
Isosceles Isosceles
Entered triangle Entered triangle
07 Testing for 5, 5, 11 5 5 11 side value is out side value is out Pass
of range of range

Entered triangle Entered triangle


08 Testing for 5, -1, 5 5 -1 5 side value is out side value is out Pass
of range of range

The triangle is The triangle is


09 Testing for 5, 1, 5 5 1 5 Pass
Isosceles Isosceles
The triangle is The triangle is
10 Testing for 5, 2, 5 5 2 5 Pass
Isosceles Isosceles
The triangle is The triangle is
11 Testing for 5, 9, 5 5 9 5 Pass
Isosceles Isosceles
The triangle The triangle
12 Testing for 5, 10, 5 5 10 5 construction is construction is not Pass
not possible possible
Entered triangle Entered triangle
13 Testing for 5, 11, 5 5 11 5 side value is out side value is out Pass
of range of range

Entered triangle Entered triangle


14 Testing for -1, 5, 5 -1 5 5 side value is out side value is out Pass
of range of range

The triangle is The triangle is


15 Testing for 1, 5, 5 1 5 5 Pass
Isosceles Isosceles
The triangle is The triangle is
16 Testing for 2, 5, 5 2 5 5 Pass
Isosceles Isosceles
The triangle is The triangle is
17 Testing for 9, 5, 5 9 5 5 Pass
Isosceles Isosceles
The triangle The triangle
18 Testing for 10, 5, 5 10 5 5 construction is construction is not Pass
not possible possible
Entered triangle Entered triangle
19 Testing for 11, 5, 5 11 5 5 side value is out side value is out Pass
of range of range

Table 4.3 Triangle Problems Worst-Case 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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 27


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

possible possible

The triangle The triangle


05 Testing for 1, 1, 10 1 1 10 construction is not construction is not Pass
possible possible
The triangle The triangle
06 Testing for 1, 2, 1 1 2 1 construction is not construction is not Pass
possible possible
The triangle is The triangle is
07 Testing for 1, 2, 2 1 2 2 Pass
Isosceles Isosceles
The triangle The triangle
08 Testing for 1, 2, 5 1 2 5 construction is not construction is not Pass
possible possible
The triangle The triangle
09 Testing for 1, 2, 9 1 2 9 construction is not construction is not Pass
possible possible
The triangle The triangle
10 Testing for 1, 2, 10 1 2 10 construction is not construction is not Pass
possible possible
The triangle The triangle
11 Testing for 1, 5, 1 1 5 1 construction is not construction is not Pass
possible possible
The triangle The triangle
12 Testing for 1, 5, 2 1 5 2 construction is not construction is not Pass
possible possible
The triangle is The triangle is
13 Testing for 1, 5, 5 1 5 5 Pass
Isosceles Isosceles
The triangle The triangle
14 Testing for 1, 5, 9 1 5 9 construction is not construction is not Pass
possible possible
The triangle The triangle
15 Testing for 1, 5, 10 1 5 10 construction is not construction is not Pass
possible possible
The triangle The triangle
16 Testing for 1, 9, 1 1 9 1 construction is not construction is not Pass
possible possible
The triangle The triangle
17 Testing for 1, 9, 2 1 9 2 construction is not construction is not Pass
possible possible
The triangle The triangle
18 Testing for 1, 9, 5 1 9 5 construction is not construction is not Pass
possible possible
The triangle is The triangle is
19 Testing for 1, 9, 9 1 9 9 Pass
Isosceles Isosceles
The triangle The triangle
20 Testing for 1, 9, 10 1 9 10 construction is not construction is not Pass
possible possible
The triangle The triangle
21 Testing for 1, 10, 1 1 10 1 construction is not construction is not Pass
possible possible
The triangle The triangle
22 Testing for 1, 10, 2 1 10 2 construction is not construction is not Pass
possible possible
The triangle The triangle
23 Testing for 1, 10, 5 1 10 5 construction is not construction is not Pass
possible possible
The triangle The triangle
24 Testing for 1, 10, 9 1 10 9 construction is not construction is not Pass
possible possible

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 28


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

The triangle is The triangle is


25 Testing for 1, 10, 10 1 10 10 Pass
Isosceles Isosceles

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 29


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

The triangle The triangle


4 WN4 4 1 2 construction is construction is Pass
not possible not possible
Because no valid subintervals of variables a, b and c exist, the strong normal equivalence class
test cases are identical to the weak normal equivalence class test cases.
Table 4.5: Weak Robust Equivalence Class Test Cases
TC Test Case Input Expected Actual
Status
ID Description a b c Output Output
Value of a is not in Value of a is not
1 WR1 -1 5 5 the range of permitted in the range of Pass
values permitted values
Value of b is not in Value of b is not
2 WR2 5 -1 5 the range of permitted in the range of Pass
values permitted values
Value of c is not in the Value of c is not
3 WR3 5 5 -1 range of permitted in the range of Pass
values permitted values
Value of a is not in Value of a is not
4 WR4 11 5 5 the range of permitted in the range of Pass
values permitted values
Value of b is not in Value of b is not
5 WR5 5 11 5 the range of permitted in the range of Pass
values permitted values
Value of c is not in the Value of c is not
6 WR6 5 5 11 range of permitted in the range of Pass
values permitted values

Table 4.6: Strong Robust Equivalence Class Test Cases


TC Test Case Input Expected Actual Status
ID Description a b c Output Output
Value of a is not in the Value of a is not in
1 SR1 -1 5 5 range of permitted the range of Pass
values permitted values
Value of b is not in the Value of b is not in
2 SR2 5 -1 5 range of permitted the range of Pass
values permitted values
Value of c is not in the Value of c is not in
3 SR3 5 5 -1 range of permitted the range of Pass
values permitted values
Value of a is not in the Value of a is not in
range of permitted the range of
values permitted values
4 SR4 -1 -1 5 Pass
Value of b is not in the Value of b is not in
range of permitted the range of
values permitted values
Value of a is not in the Value of a is not in
range of permitted the range of
values permitted values
5 SR5 -1 5 -1 Pass
Value of c is not in the Value of c is not in
range of permitted the range of
values permitted values
Value of b is not in the Value of b is not in
range of permitted the range of
6 SR6 5 -1 -1 Pass
values permitted values
Value of c is not in the Value of c is not in

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 30


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

range of permitted the range of


values permitted values
Value of a is not in the Value of a is not in
range of permitted the range of
values permitted values
Value of b is not in the Value of b is not in
7 SR7 11 -1 -1 range of permitted the range of Pass
values permitted values
Value of c is not in the Value of c is not in
range of permitted the range of
values permitted values

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;

public class TriangleChecker {


public static void main(String[] args) {

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 31


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

int a, b, c;
int flag = -1;
Scanner scanner = new Scanner(System.in);

System.out.print("Enter the values of a, b and c: ");


a = scanner.nextInt();
b = scanner.nextInt();
c = scanner.nextInt();

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 32


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

The decision table in Table 1 illustrates the Triangle Problem


Action: Not a Triangle
When c1 fails, the three integers a, b & c do not constitute sides of a triangle
If any one of the condition c1, c2 & c3 fails, the three integers a, b & c do not constitute sides of a
triangle hence it’s Not a Triangle
Action: Scalene
When conditions c1, c2 & c3 are true and c4, c5 & c6 are false, then action is Scalene Triangle
means all sides are not equal
Action: Isosceles
When conditions c1, c2 & c3 are true and if any two condition among c4, c5 & c6 are false then
action is Isosceles Triangle
Action: Equilateral
If all the conditions c1, c2, c3, c4, c5 & c6 are true then action is Equilateral Triangle means all
sides are equal.
Action: Impossible
If conditions c1, c2 & c3 are true and two conditions among c4, c5 & c6 is true , then no 1
condition to be false hence it is Impossible
Test Cases:
Based on Decision Table-Based Testing, we can derive 11 test cases: 3 test cases for failing
triangle property, 1 case for Scalene, 3 cases for Isosceles, 1 case for Equilateral and 3 cases for
Impossible.
Table 4.8: Test cases for the Triangle Problem
Test Case Input Expected Actual
TC ID Observation
Description a b c Output Output
The triangle The triangle
Testing for construction construction
01 7 2 3 Pass
Not a Triangle is not is not
possible possible
The triangle The triangle
Testing for
02 2 7 3 construction construction Pass
Not a Triangle
is not is not

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 33


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 34


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 35


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Step 1: Define locks_price = 45 $, stock_price= 30$, barrel_price = 25 $


Step 2: Input (locks)
Step 3: while (locks !=-1) ‘Input device uses -1 to indicate end of data’
Input (stocks, barrels)
calculate total_locks, total_stocks, total_barrels
Input (locks)
End while
Step 4: calculate total sales
total_sales = (total_locks *45) + ( total_stocks*30) + (total_barrels * 25)

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 36


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

Step 5: if (total_sales <= 1000)


commission = 0.10 * total_sales;
else if (total_sales < 1800)
{
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, totalSales;
float commission = 0.0f;

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();
}

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 37


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

if ((totalLocks >= 0 && totalLocks <= 70) && (totalStocks >= 0 && totalStocks <=
80) && (totalBarrels >= 0 && 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();
}
}

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).

DEF(v, n): Node n ϵ G(P) is a defining node of the variable v ϵ V, written as


DEF(v, n), iff the value of the variable v is defined at the statement fragment corresponding to
node n.

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 38


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

dc-path: A definition-clear path with respect to a variable v (dc-path) is a definition-use path in


PATHS(P) with initial and final nodes DEF (v, m) and USE (v, n) such that no other node in the
path is a defining node of v.

DATA FLOW TESTING: KEY STEPS


For a given program:
1. Assign the line numbers to the program
2. List define & use nodes for variables.
3. List occurrences & assign a category for each variable.
4. Identify du-pairs and their p-use and c-use
5. Define test cases, depending on the required coverage.
Table 5.1: Define/Use Nodes for Variables in the Commission Problem
Variable Defined at Node Used at Node
total_locks 5, 15 15, 21
total_stocks 5, 16 16, 21
total_barrels 5, 17 17, 21
Locks 8, 19 9, 15
stocks 12 16
barrels 14 17
total_sales 22 23, 24, 26, 28, 33, 35
Commission 6, 24, 27, 28, 31, 32, 33 28. 32, 33, 35

Table 5.2: Occurrences and assignment of category for each variable


line no. Catogary
Definition c-use p-use
total_locks
5 total_stocks
total_barrels
6 commission
7
8 locks
9 locks
10
11
12 stocks
13
14 barrels
15 total_locks total_locks, locks

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 39


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

16 total_stocks total_stocks, stocks


total_barrels,
17 total_barrels
barrels
18
19 locks
20
total_locks
21 total_stocks
total_barrels
total_locks
22 total_sales total_stocks
total_barrels
23 total_sales
24 commission total_sales
25
26 total_sales
27 commission
total_sales
28 commission
commission
29
30
31 commission
32 commission commission
total_sales
33 commission
commission
34
total_sales
35
commission

Table 9.3: Define / Use Paths for variables


Variables definition - use pair
Beginning node → end
Node
5 →15
total_locks 5 →21
15 →21
total_stocks 5 →16
5 →21
16 →21
total_barrels 5 →17
5 →21
17 →21
8 →9
8 →15
locks
19 →9
19 →15
stocks 12 →16
barrels 14 →17

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 40


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

2 8 →15 8, 9, 15 35 40 45 3900 640 640 Pass

3 19 →9 19 →9 -1 40 45 Invalid Pass

4 19 →15 19, 9,15 35 40 45 3900 640 640 Pass

5 stocks 12 →16 12 →16 35 40 - - - - Pass

6 barrels 14 →17 14 →17 35 40 45 3900 640 640 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

9 22 →26 22 →26 14 14 14 1400 160 160 Pass

10 22 →28 22, 26, 28 14 14 14 1400 160 160 Pass

11 22 →33 22 →33 48 48 48 4800 820 820 Pass

22, 23, 26, Pass


12 22 →35 35 40 45 3900 640 640
33
commissi Pass
13 24 →35 24 →35 5 5 5 500 50 50
on
14 28 →35 28 →35 14 14 14 1400 160 160 Pass

15 33 →35 33 →35 48 48 48 4800 820 820 Pass

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 41


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Possible Viva Questions and answers

1. How is data flow in a program tested?


Dataflow Testing focuses on the points at which variables receive values and the
points at which these values are used.
2. What is Du path?
A du-path is a simple path where the initial node of the path is the only defining
node of x in the path and final node of the path is the use node.
3. What is DC path?
A definition-clear (sub)path with respect to a variable v (denoted as dc-path) is a definition-
use path in PATHS(P) with initial nodes DEF(v, m) and USE(v, n) such that there no other
node in the path is a defining node for v.
4. What is data flow diagram?
A data-flow diagram (DFD) is a way of representing a flow of a data of a process or a system
(usually an information system). The DFD also provides information about the outputs and
inputs of each entity and the process itself.
5. What is slice based testing?
Slice Based Testing is to test the program with various subsets (called slices) of program
with respect to its variables and their selected locations in the program.
6. What is P use?
If the variable is in a predicate statement and its value is used to decide an execution path is
called P use.
7. What is c-use?
Use of a variable is a. computation use (c-use) if the value of the variable is used
to compute a value for defining another variable or as an output value.
8. What is the value of locks, stocks, and barrel?
Cost of Locks=$25

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 42


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 43


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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;

public class BinarySearch {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int i, low, high, mid, n, key, array[] = new int[100];

System.out.println("Enter the number of elements in the array");


n = scanner.nextInt();

System.out.printf("Enter %d elements into the array\n", n);


for (i = 0; i < n; i++) {

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 44


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

array[i] = scanner.nextInt();
}

System.out.println("Enter the key element to be searched");


key = scanner.nextInt();

low = 0;
high = n - 1;

while (low <= high) {


mid = (low + high) / 2;
if (array[mid] == key) {
System.out.printf(" The key element %d found at location %d.\n", key, mid +
1);
return;
} else if (array[mid] < key) {
low = mid + 1;
} else {
high = mid - 1;
}
}

if (low > high) {


System.out.printf("The key element %d not found \n", key);
}
}
}

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

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 45


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

Fig 6.1: Program Graph for Binary Search Program

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 46


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

Table 6.1: DD-Path in Fig 6.1


Program Graph Nodes DD-Path
5 First
6-7 A
8 B
9 C
10-13 D
14 E
15 F
16 G
17-19 H
20 I
21 J
23 K
24 L
25 M
26 N
27 O
28 Last

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 47


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

Step 2: Calculate the cyclomatic complexity


The formula for cyclomatic complexity is given by

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 48


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

V(G) = e - n + p or V(G) = e - n + 2p

Where, e: is the number of edges


n: is the number of nodes
p: is the number of connected regions
The number of linearly independent paths from the source node to the sink node in
Fig. 10.2 is
V(G) = e - n + 2p = 21 - 17 + 2(1) = 6

Step 3: The six linearly independent paths of our graph are as follows:

P1: First, A, B, C, B, D, E, F, G, H, L, M, O, Last


P2: First, A, B, C, B, D, E, F, G, I, J, E, F, G, H, L, M, O, Last
P3: First, A, B, C, B, D, E, F, G, I, K, E, F, G, H, L, M, O, Last
P4: First, A, B, D, E, L, M, N, Last
P5: First, A, B, C, B, D, E, F, G, I, J, E, L, M, N, O, Last
P6: First, A, B, C, B, D, E, F, G, I, K, E, L, M, N, O, Last
Step 4: Deriving test cases using Basis Path Testing
TC Test Case Value array Expected Actual
key Status
ID Description of ‘n‘ elements Output Output
The key The key
Testing for element 6 element 6
1 5 2,4,6,8,10 6 Pass
Path P1 found at found at
location 3 location 3
The key The key
Testing for element 4 element
2 5 2,4,6,8,10 4 Pass
Path P2 found at found at
location 2 location 2
The key The key
Testing for element 10 element 10
3 5 2,4,6,8,10 10 Pass
Path P3 found at found at
location 5 location 5
Testing for Key element 5 Key element
4 0 ---------- 5 Pass
Path P4 not found 5 not found
Testing for Key element 1 Key element
5 5 2,4,6,8,10 1 Pass
Path P5 not found 1 not found
Testing for Key element 11 Key element
6 5 2,4,6,8,10 11 Pass
Path P6 not found 11 not found

EXECUTION & RESULT DISCUSION:


Execute the program against the designed test cases and complete the table for Actual output
column and status column.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 49


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

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

1. What is the motivation of path testing?


Path testing follows a process of control flow or workflow, rather than executing
the process of testing on the basis of specifications
2. What is basis path testing in software testing?
Basis path testing is the control flow graph of a program to find a set of linearly
independent paths of execution.
3. What are the advantages of path testing?
➢ Path testing is mainly focused on the program logic.
➢ It allows the team to analyze the flow of the program during the process of testing.
➢ It is highly dependent on the source code of the program and ensures the execution of the
each and every path, present in the software program, at least once.
4. What is condition testing?
Condition Testing is another structural testing method that is useful during
unit testing, using source code or detailed pseudo code as a reference
for test design. Its goal is the thorough testing of every condition or test that occurs
in the source code.
5. How do you write a binary search?
Binary Search: Search a sorted array by repeatedly dividing the search interval in
half. Begin with an interval covering the whole array. If the value of
the search key is less than the item in the middle of the interval, narrow the
interval to the lower half. Otherwise narrow it to the upper half.
6. What are independent paths?
Independent path is defined as a path that has at least one edge which has not been
traversed before in any other paths.
7. What is the role of Cyclomatic complexity in software testing?
Cyclomatic complexity is a software metric used to measure the complexity of a
program. These metric measures independent paths through program source code.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 50


SOFTWARE TESTING LABORATORY (21ISL66) MANUAL

Cyclomatic complexity can be calculated with respect to functions, modules,


methods or classes within a program.
8. Define Cyclomatic complexity
Cyclomatic complexity = E - N + 2*P where, E = number of edges in the flow
graph. N = number of nodes in the flow graph. P = number of nodes that have
exit points.
9. What is a good cyclomatic complexity score?
For most routines, a cyclomatic complexity below 4 is considered good
10. What are test metrics?
Software testing metrics are a way to measure and monitor your test activities.

Practical Based Learning


Develop a Mini Project with documentation of suitable test-cases and their results
to perform automation testing of any E-commerce or social media web page.

Dept. of ISE, S.D.M. Institute of Technology, Ujire Page 51

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy