0% found this document useful (0 votes)
6 views

stqaLabFile - Garima Gupta

Uploaded by

shivanjali.k21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

stqaLabFile - Garima Gupta

Uploaded by

shivanjali.k21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

INDIRA GANDHI DELHI TECHNICAL

UNIVERSITY FOR WOMEN


ACADEMIC YEAR: 2022-2024

Software Testing And


Quality Assurance
LAB FILE

Submitted by: Submitted to:


Garima Gupta Dr. Ankita
(02004092022)
Exp. Experiment Title Page Date
No. No.
1. Types of Software Testing Tools
2. Adhoc Testing
3. Boundary Value Analysis
4. Robustness Testing Technique
5. Worst-Case Testing Technique
6. Robust Worst-Case Testing Technique
7. Equivalence Class Testing Technique
8. Decision Table Based Testing
9. Control Flow Testing
10. Data Flow Testing
11. Modification Algorithm
12. Deletion Algorithm
EXPERIMENT 1.
Types of Testing Software
1. Cucumber

Cucumber is a popular automated software testing tool that supports Behavior Driven
Development (BDD), which is a software development process that implements important
acceptance test scenarios while development is in progress in order to help organizations get
most out of software testing.

While Cucumber was originally used exclusively for Ruby testing, it now supports a variety
of different programming languages through various implementations, including JavaScript,
Java, PHP, and Lua. Cucumber also features its own programming language, called Gherkin.
Used to define test cases, Gherkin was designed to be human-readable, and its purpose is
to promote BDD practices.

Cucumber is perfect for those who would like to focus on the end-user experience and
involve even those stakeholders who can’t code. It’s also free, easy to set up, and has been
downloaded over 30 million times, making it the world’s most popular automated software
testing tool for BDD.

2. Selenium

Selenium is arguably the most popular automated software testing tool among web
developers and testers. It was first released in 2004, and it has evolved considerably since
then. The latest version of Selenium consists of several components, including Selenium IDE
and Selenium WebDriver.

Selenium IDE is a complete integrated development environment (IDE) for Selenium tests,
and it’s used primarily for creating quick bug reproduction scripts and scripts to help in
automation-aided exploratory testing. On the other hand, Selenium WebDriver is a collection
of language-specific bindings to drive a browser, and it was developed to better support
dynamic web pages.

Selenium is compatible with all major web browsers and supports a number of popular
programming languages, including JavaScript, Java, Ruby, Python, PHP, and C#, just to
name a few. While Selenium makes it possible to author automation tests without any
programming skills, complex test scripts require advanced programming skills.

Considering that Selenium is free, open source, and enjoys the support of some of the largest
browser vendors, all automation testers who want to be competitive should see Selenium as a
professional investment and at the very least familiarize themselves with it.
3. Appium

Appium is an automated software testing tool for use with native, hybrid, and mobile web
apps. With mobile apps on the rise and major app stores becoming increasingly competitive,
there is an urgent need to deliver only quality apps to the consumer.

he goal of Appium is to automate mobile app testing without an SDK or recompilation.


Appium allows testers to write test using their favorite tools and programming languages.
Getting started with Appium could hardly be any easier, and this remarkable automated
software testing tool is open source and hosted publicly on GitHub.

Appium has been successfully used to automate large regression tests, convert manual test
cases to automated scripts, and more. Because it supports both Android and iOS, there’s no
need to learn a new language for each platform, which saves time and aligns with the needs
of most app developers.

4. Katalon Studio

Katalon Studio is a cross-platform automation testing solution built on top of the Selenium
and Appium frameworks. It’s completely free, easy to deploy, and its active community of
over 100,000 automation testers has created a wealth of tutorials and guides that make
learning how to use Katalon Studio effortless.

Non-programmers can use Katalon Studio to record test scripts, while automation testers with
some programming knowledge can explore some of the more advanced features of Katalon
Studio and create powerful automation scripts using Groove, Java, or JavaScript.

Katalon Studio works well with popular tools in the QA process, and it can be integrated into
the CI/CD processes. There’s also a streamlined version of Katalon Studio, called Katalon
Recorder, and it can be installed in just a few seconds on both Chrome and Firefox.

5. Eggplant Functional

Eggplant Functional was conceived by Doug Simons, Jonathan Gillaspie, and John McIntosh
and first released in 2002 by Redstone Software. Unlike other automated software testing
tools on this list, Eggplant Functional uses an image-based approach to testing, as opposed to
looking at the tested application from the object perspective. This means that the technology
used to build the tested application is irrelevant, as is the system on which the application
runs.

Plug-ins for some of the most popular continuous integration and application lifecycle
management (ALM) tools are available, including IBM UrbanCode, Bamboo, HP
Application Lifecycle Management, IBM RQM, and Jenkins, among others. Because
Eggplant Functional has secured a patent for its intelligent image recognition method, it has
been able to enjoy a somewhat privileged position on the market, but its accomplishments
stand on their own.
CODE
import java.util.Scanner;

class MatrixOperations {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Input for size of matrices

System.out.print("Enter size for the 2D matrices: ");

int size = input.nextInt();

int[][] matrix1 = new int[size][size];

System.out.println("Enter the values for Matrix 1:");

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

matrix1[i][j] = input.nextInt();

int[][] matrix2 = new int[size][size];

System.out.println("Enter the values for Matrix 2:");

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

matrix2[i][j] = input.nextInt();

//Perform Matrix Addition

int[][] sumMatrix = new int[size][size];

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

sumMatrix[i][j] = matrix1[i][j] + matrix2[i][j];

// Perform matrix subtraction


int[][] diffMatrix = new int[size][size];

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

diffMatrix[i][j] = matrix1[i][j] - matrix2[i][j];

displayMatrix(sumMatrix);

displayMatrix(diffMatrix);

public static void displayMatrix(int[][] matrix) {

for (int[] row : matrix) {

for (int value : row) {

System.out.print(value + " ");

System.out.println();

}
EXPERIMENT 2.

Adhoc Testing

Adhoc testing is a type of software testing which is performed informally and randomly after
the formal testing is completed to find out any loophole in the system. For this reason, it is
also known as Random testing or Monkey testing. Adhoc testing is not performed in an
structured way so it is not based on any methodological approach. That’s why Adhoc testing
is a type of Unstructured Software Testing.

Test Case ID Test Cases Expected Output Actual Output


Matrix 1 Matrix 2
1. Addition Addition
50 50 50 50 100 100 100 100

1 50 50 50 51 100 51 100

Subtraction
Subtraction
0 0
0 0

-49 0
-49 0

2. Addition Addition
50 50 50 50 100 100 100 100

2 50 50 50 52 100 52 100
Subtraction
Subtraction
0 0
0 0
-48 0
-48 0

3. Addition Addition
50 50 50 50 100 100 100 100

99 50 50 50 149 100 149 100


Subtraction
Subtraction
0 0
0 0
49 0
49 0

4. Addition Addition
50 50 50 50 100 100 100 100

100 50 50 50 150 100 150 100


Subtraction
Subtraction
0 0
0 0
50 0
50 0

5. Addition Addition
50 50 50 50 100 100 100 100

50 1 50 50 100 51 100 51
Subtraction Subtraction
0 0 0 0

0 -49 0 -49

6. Addition Addition
50 50 50 50 100 100 100 100

50 2 50 50 100 52 100 52
Subtraction
Subtraction
0 0
0 0
0 -48
0 -48

7. Addition Addition
50 50 50 50 100 100 100 100

50 99 50 50 100 149 100 149


Subtraction
Subtraction
0 0
0 0
0 49
0 49

8. Addition Addition
50 50 50 50 100 100 100 100

50 100 50 50 100 150 100 150


Subtraction
Subtraction
0 0
0 0
0 50
0 50

1. Addition Addition
Invalid Input
101 50 50 50 151 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
51 0

0 0

2. Addition Addition
Invalid Input
50 0 50 50 100 50
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
0 -50

0 0

The test case generated randomly gives correct performance when the test cases are within
the range while they give wrong results when the inputs are beyond the given range.
EXPERIMENT 3.

Boundary Value Testing

Boundary Value Analysis is based on testing the boundary values of valid and invalid
partitions. The behavior at the edge of the equivalence partition is more likely to be incorrect
than the behavior within the partition, so boundaries are an area where testing is likely to
yield defects.
It checks for the input values near the boundary that have a higher chance of error. Every
partition has its maximum and minimum values and these maximum and minimum values are
the boundary values of a partition.
Boundary Value Test Cases are: -

For elements of matrix1 and matrix 2:

● Min value = 1
● Close to min = 2
● Nominal = 50
● Close to max = 99
● Max = 100

Total no of Test Cases is, 4n+1 => 4*8+1 = 33

Test Case ID Test Cases Expected Output Actual Output


Matrix 1 Matrix 2
1. Addition Addition
1 50 50 50 51 100 51 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
–49 0
-49 0
0 0
0 0

2. Addition Addition
2 50 50 50 52 100 52 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
-48 0
-48 0
0 0
0 0
3. Addition Addition
50 50 50 50 100 100 100 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 0
0 0
0 0
0 0

4. Addition Addition
99 50 50 50 149 100 149 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
49 0
49 0
0 0
0 0

5. Addition Addition
100 50 50 50 150 100 150 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
50 0
50 0
0 0
0 0

6. Addition Addition
50 1 50 50 100 51 100 51

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -49
0 -49
0 0
0 0

7. Addition Addition
50 2 50 50 100 52 100 52

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -48
0 -48
0 0
0 0

8. Addition Addition
50 99 50 50 100 149 100 149

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 49
0 49
0 0
0 0

9. Addition Addition
50 100 50 50 100 150 100 150

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 50
0 50
0 0
0 0

10. Addition Addition


50 50 50 50 100 100 100 100

1 50 50 50 51 100 51 100
Subtraction
Subtraction
0 0
0 0
-49 0
-49 0

11. Addition Addition


50 50 50 50 100 100 100 100

2 50 50 50 52 100 52 100
Subtraction
Subtraction
0 0
0 0
-48 0
-48 0

12. Addition Addition


50 50 50 50 100 100 100 100

99 50 50 50 149 100 149 100


Subtraction
Subtraction
0 0
0 0
49 0
49 0

13. Addition Addition


50 50 50 50 100 100 100 100

100 50 50 50 150 100 150 100


Subtraction
Subtraction
0 0
0 0
50 0
50 0

14. Addition Addition


50 50 50 50 100 100 100 100

50 1 50 50 100 51 100 51
Subtraction
Subtraction
0 0
0 0
0 -49
0 -49

15. Addition Addition


50 50 50 50 100 100 100 100
50 2 50 50 100 52 100 52
Subtraction
Subtraction
0 0
0 0
0 -48
0 -48

16. Addition Addition


50 50 50 50 100 100 100 100

50 99 50 50 100 149 100 149


Subtraction
Subtraction
0 0
0 0
0 49
0 49

17. Addition Addition


50 50 50 50 100 100 100 100

50 100 50 50 100 150 100 150


Subtraction
Subtraction
0 0
0 0
0 50
0 50

18. Addition Addition


50 50 1 50 51 100 51 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
49 0
49 0
0 0
0 0

19. Addition Addition


50 50 2 50 52 100 52 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
48 0
48 0
0 0
0 0

20. Addition Addition


50 50 99 50 149 100 149 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
-49 0
-49 0
0 0
0 0

21. Addition Addition


50 50 100 50 150 100 150 100

50 50 50 50 100 100
Subtraction
100 100
-50 0
Subtraction
0 0
-50 0

0 0

22. Addition Addition


50 50 50 1 100 51 100 51

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 49
0 49
0 0
0 0

23. Addition Addition


50 50 50 2 100 52 100 52

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 48
0 48
0 0
0 0

24. Addition Addition


50 50 50 99 100 149 100 149

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -49
0 -49
0 0
0 0

25. Addition Addition


50 50 50 100 100 100 100 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -50
0 -50
0 0
0 0

26. Addition Addition


50 50 50 50 100 100 100 100

50 50 1 50 51 100 51 100
Subtraction
Subtraction
0 0
0 0
49 0
49 0

27. Addition Addition


50 50 50 50 100 100 100 100

50 50 2 50 52 100
Subtraction
52 100
0 0
Subtraction
48 0
0 0

48 0

28. Addition Addition


50 50 50 50 100 100 100 100

50 50 99 50 149 100 149 100


Subtraction
Subtraction
0 0
0 0
-49 0
-49 0

29. Addition Addition


50 50 50 50 100 100 100 100

50 50 100 50 150 100 150 100


Subtraction
Subtraction
0 0
0 0
-50 0
-50 0

30. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 1 100 51 100 51
Subtraction
Subtraction
0 0
0 0
0 49
0 49

31. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 2 100 52 100 52
Subtraction
Subtraction
0 0
0 0
0 48
0 48

32. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 99 100 149 100 149


Subtraction
Subtraction
0 0
0 0
0 -49
0 -49
33. Addition Addition
50 50 50 50 100 100 100 100

50 50 50 100 100 150 100 150


Subtraction
Subtraction
0 0
0 0
0 -50
0 -50

The test cases in the Boundary Level Testing Technique gives correct output when run the
the given program.
EXPERIMENT 4.

Robustness Testing

Robustness is a measure of how well a software system can cope with invalid inputs or
unexpected user interactions. A robust system is one that continues to function correctly even
in the face of unexpected or invalid inputs. A software system that is robust is able to handle
errors and unexpected inputs gracefully, without crashing or producing incorrect results.

For elements of matrix1 and matrix 2:

● Min value = 1
● Close to min = 2
● Lesser than min value = 0
● Nominal = 50
● Close to max = 99
● Max = 100
● Larger than max value = 101

Total no of Test Cases is, 6n+1 => 6*8+1 = 49

Test Case ID Test Cases Expected Output Actual Output


Matrix 1 Matrix 2
3. Addition Addition
Invalid Input
0 50 50 50 50 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
–50 0

0 0

4. Addition Addition
1 50 50 50 51 100 51 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
–49 0
-49 0
0 0
0 0

5. Addition Addition
2 50 50 50 52 100 52 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
-48 0
-48 0
0 0
0 0
6. Addition Addition
50 50 50 50 100 100 100 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 0
0 0
0 0
0 0

7. Addition Addition
99 50 50 50 149 100 149 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
49 0
49 0
0 0
0 0

8. Addition Addition
100 50 50 50 150 100 150 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
50 0
50 0
0 0
0 0

9. Addition Addition
Invalid Input
101 50 50 50 151 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
51 0

0 0

10. Addition Addition


Invalid Input
50 0 50 50 100 50
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
0 -50

0 0

11. Addition Addition


50 1 50 50 100 51 100 51

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -49
0 -49
0 0
0 0
12. Addition Addition
50 2 50 50 100 52 100 52

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -48
0 -48
0 0
0 0

13. Addition Addition


50 99 50 50 100 149 100 149

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 49
0 49
0 0
0 0

14. Addition Addition


50 100 50 50 100 150 100 150

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 50
0 50
0 0
0 0

15. Addition Addition


Invalid Input
50 101 50 50 100 151
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
0 51

0 0

16. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
0 50 50 50 Invalid Input
50 100
Subtraction
0 0

-50 0

17. Addition Addition


50 50 50 50 100 100 100 100

1 50 50 50 51 100 51 100
Subtraction
Subtraction
0 0
0 0
-49 0
-49 0

18. Addition Addition


50 50 50 50 100 100 100 100
2 50 50 50 52 100 52 100
Subtraction
Subtraction
0 0
0 0
-48 0
-48 0

19. Addition Addition


50 50 50 50 100 100 100 100

99 50 50 50 149 100 149 100


Subtraction
Subtraction
0 0
0 0
49 0
49 0

20. Addition Addition


50 50 50 50 100 100 100 100

100 50 50 50 150 100 150 100


Subtraction
Subtraction
0 0
0 0
50 0
50 0

21. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
101 50 50 50 Invalid Input
151 100
Subtraction
0 0

51 0

22. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 0 50 50 Invalid Input
100 50
Subtraction
0 0

0 -50

23. Addition Addition


50 50 50 50 100 100 100 100

50 1 50 50 100 51 100 51
Subtraction
Subtraction
0 0
0 0
0 -49
0 -49

24. Addition Addition


50 50 50 50 100 100 100 100

50 2 50 50 100 52 100 52
Subtraction
Subtraction
0 0
0 0
0 -48
0 -48

25. Addition Addition


50 50 50 50 100 100 100 100

50 99 50 50 100 149 100 149


Subtraction
Subtraction
0 0
0 0
0 49
0 49

26. Addition Addition


50 50 50 50 100 100 100 100

50 100 50 50 100 150 100 150


Subtraction
Subtraction
0 0
0 0
0 50
0 50

27. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 101 50 50 Invalid Input
100 151
Subtraction
0 0

0 51

28. Addition Addition


Invalid Input
50 50 0 50 50 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
50 0

0 0

29. Addition Addition


50 50 1 50 51 100 51 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
49 0
49 0
0 0
0 0

30. Addition Addition


50 50 2 50 52 100 52 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
48 0
48 0
0 0 0 0

31. Addition Addition


50 50 99 50 149 100 149 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
-49 0
-49 0
0 0
0 0

32. Addition Addition


50 50 100 50 150 100 150 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
-50 0
-50 0
0 0
0 0

33. Addition Addition


Invalid Input
50 50 101 50 151 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
-51 0

0 0

34. Addition Addition


Invalid Input
50 50 50 0 100 50
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
0 50

0 0

35. Addition Addition


50 50 50 1 100 51 100 51

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 49
0 49
0 0
0 0

34. Addition Addition


50 50 50 2 100 52 100 52

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 48
0 48
0 0
0 0

35. Addition Addition


50 50 50 99 100 149 100 149

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -49
0 -49
0 0
0 0

36. Addition Addition


50 50 50 100 100 150 100 150

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 -50
0 -50
0 0
0 0

37. Addition Addition


Invalid Input
50 50 50 101 100 151
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
0 -51

0 0

38. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 50 0 50 Invalid Input
50 100
Subtraction
0 0

50 0

39. Addition Addition


50 50 50 50 100 100 100 100

50 50 1 50 51 100 51 100
Subtraction
Subtraction
0 0
0 0
49 0
49 0

40. Addition Addition


50 50 50 50 100 100 100 100

50 50 2 50 52 100 52 100
Subtraction
Subtraction
0 0
0 0
48 0
48 0

41. Addition Addition


50 50 50 50 100 100 100 100
50 50 99 50 149 100 149 100
Subtraction
Subtraction
0 0
0 0
-49 0
-49 0

42. Addition Addition


50 50 50 50 100 100 100 100

50 50 100 50 150 100 150 100


Subtraction
Subtraction
0 0
0 0
-50 0
-50 0

43. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 50 101 50 Invalid Input
151 100
Subtraction
0 0

-51 0

44. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 50 50 0 Invalid Input
100 50
Subtraction
0 0

0 50

45. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 1 100 51 100 51
Subtraction
Subtraction
0 0
0 0
0 49
0 49

46. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 2 100 52 100 52
Subtraction
Subtraction
0 0
0 0
0 48
0 48
47. Addition Addition
50 50 50 50 100 100 100 100

50 50 50 99 100 149 100 149


Subtraction
Subtraction
0 0
0 0
0 -49
0 -49

48. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 100 100 150 100 150


Subtraction
Subtraction
0 0
0 0
0 -50
0 -50

49. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 50 50 101 Invalid Input
100 151
Subtraction
0 0

0 -51

Since the test cases in Robust Worst Case Testing Technique gives wrong answers for the test
cases generated beyond the given range, we have made corrections in the program to handle
these type of test cases.

Correct Program to handle the robust Test Cases :

class MatrixOperations {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Input for Matrix 1

System.out.print("Enter size for the 2D matrices: ");

int size = input.nextInt();

boolean flag=true;

int[][] matrix1 = new int[size][size];

System.out.println("Enter the values for Matrix 1:");

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

int val=input.nextInt();
if(val<1 || val>100){

flag=false;

matrix1[i][j] = val;

// Input for Matrix 2

int[][] matrix2 = new int[size][size];

System.out.println("Enter the values for Matrix 2:");

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

int val=input.nextInt();

if(val<1 || val>100){

flag=false;

matrix2[i][j] = val;

if(flag==true){

// Perform matrix addition

int[][] sumMatrix = new int[size][size];

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {

sumMatrix[i][j] = matrix1[i][j] + matrix2[i][j];

// Perform matrix subtraction

int[][] diffMatrix = new int[size][size];

for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {


diffMatrix[i][j] = matrix1[i][j] - matrix2[i][j];

displayMatrix(sumMatrix);

displayMatrix(diffMatrix);

}else{

System.out.println("Invalid Input");

public static void displayMatrix(int[][] matrix) {

for (int[] row : matrix) {

for (int value : row) {

System.out.print(value + " ");

System.out.println();

}
EXPERIMENT 5.

Worst Case Testing

If we reject “single” fault assumption theory of reliability, and consider cases where more
than 1 variable has extreme values, then it is known as worst case analysis.

Total no. of test cases,

5n = 58 = 390625 cases

Mathematically, the test cases will be a cross product of 2 sets –

{1, 2, 50, 99, 100} * {1, 2, 50, 99, 100}

We will be considering both the matrices as separate variables where values in one matrix
will be same and hence number of test cases = 5^2 = 25 test cases

Test Case ID Test Cases Expected Output Actual Output


Matrix 1 Matrix 2
1. Addition Addition
1 1 1 1 2 2 2 2

1 1 1 1 2 2 2 2

Subtraction Subtraction
0 0 0 0

0 0 0 0

2. Addition Addition
1 1 2 2 3 3 3 3

1 1 2 2 3 3 3 3
Subtraction
Subtraction
-1 -1
-1 -1
-1 -1
-1 -1

3. Addition Addition
1 1 50 50 51 51 51 51

1 1 50 50 51 51 51 51
Subtraction
Subtraction
-49 -49
-49 -49
-49 -49
-49 -49
4. Addition Addition
1 1 99 99 100 100 100 100

1 1 99 99 100 100 100 100


Subtraction
Subtraction
-98 -98
-98 -98
-98 -98
-98 -98

5. Addition Addition
1 1 100 100 101 101 101 101

1 1 100 100 101 101 101 101


Subtraction
Subtraction
-99 -99
-99 -99
-99 -99
-99 -99

6. Addition Addition
2 2 1 1 3 3 3 3

2 2 1 1 3 3 3 3
Subtraction
Subtraction
1 1
1 1
1 1
1 1

7. Addition Addition
2 2 2 2 4 4 4 4

2 2 2 2 4 4 4 4
Subtraction
Subtraction
0 0
0 0
0 0
0 0

8. Addition Addition
2 2 50 50 52 52 52 52

2 2 50 50 52 52 52 52
Subtraction
Subtraction
-48 -48
-48 -48
-48 -48
-48 -48

9. Addition Addition
2 2 99 99 101 101 101 101

2 2 99 99 101 101 101 101


Subtraction
Subtraction
-97 -97
-97 -97
-97 -97
-97 -97

10. Addition Addition


2 2 100 100 102 102 102 102

2 2 100 100 102 102 102 102


Subtraction
Subtraction
-98 -98
-98 -98
-98 -98
-98 -98

11. Addition Addition


50 50 1 1 51 51 51 51

50 50 1 1 51 51 51 51
Subtraction
Subtraction
49 49
49 49
49 49
49 49

12. Addition Addition


50 50 2 2 52 52 52 52

50 50 2 2 52 52 52 52
Subtraction
Subtraction
48 48
48 48
48 48
48 48

13. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 0
0 0
0 0
0 0

14. Addition Addition


50 50 99 99 149 149 149 149

50 50 99 99 149 149 149 149


Subtraction
Subtraction
-49 -49
-49 -49
-49 -49
-49 -49

15. Addition Addition


50 50 100 100 150 150 150 150

50 50 100 100 150 150 150 150


Subtraction
Subtraction
-50 -50
-50 -50
-50 -50
-50 -50

16. Addition Addition


99 99 1 1 100 100 100 100
99 99 1 1 100 100 100 100
Subtraction
Subtraction
98 98
98 98
98 98
98 98

17. Addition Addition


99 99 2 2 101 101 101 101

99 99 2 2 101 101 101 101


Subtraction
Subtraction
97 97
97 97
97 97
97 97

18. Addition Addition


99 99 50 50 149 149 149 149

99 99 50 50 149 149 149 149


Subtraction
Subtraction
49 49
49 49
49 49
49 49

19. Addition Addition


99 99 99 99 198 198 198 198

99 99 99 99 198 198 198 198


Subtraction
Subtraction
0 0
0 0
0 0
0 0

20. Addition Addition


99 99 100 100 199 199 199 199

99 99 100 100 199 199 199 199


Subtraction
Subtraction
-1 -1
-1 -1
-1 -1
-1 -1

21. Addition Addition


100 100 1 1 101 101 101 101

100 100 1 1 101 101 101 101


Subtraction
Subtraction
99 99
99 99
99 99
99 99

22. Addition Addition


100 100 2 2 102 102 102 102

100 100 2 2 102 102


Subtraction
102 102
98 98
Subtraction
98 98
98 98

98 98

23. Addition Addition


100 100 50 50 150 150 150 150

100 100 50 50 150 150 150 150


Subtraction
Subtraction
50 50
50 50
50 50
50 50

24. Addition Addition


100 100 99 99 199 199 199 199

100 100 99 99 199 199 199 199


Subtraction
Subtraction
1 1
1 1
1 1
1 1

25. Addition Addition


100 100 100 100 200 200 200 200

100 100 100 100 200 200 200 200


Subtraction
Subtraction
0 0
0 0
0 0
0 0

All Test Cases in Worst Test Cases Testing Technique generated results in the correct output
as changes were made in the program.
EXPERIMENT 6.

Robust Worst-Case Testing

In robustness testing, we add two more states i.e. just below minimum value (minimum
value– ) and just above maximum value (maximum value+ ). We also give invalid inputs and
observe the behaviour of the program. A program should be able to handle invalid input
values, otherwise it may fail and give unexpected output values.

Total no. of test cases,

7n = 78 = 5764801 cases

Mathematically, the test cases will be a cross product of 2 sets –

{0, 1, 2, 50, 99, 100, 101} * {0, 1, 2, 50, 99, 100, 101}

We will be considering both the matrices as separate variables where values in one matrix
will be similar and hence the number of test cases = 7^2 = 49 test cases

Test Case ID Test Cases Expected Output Actual Output


Matrix 1 Matrix 2
1. Addition Addition
Invalid Input Invalid Input
0 0 0 0
Subtraction Subtraction
0 0 0 0 Invalid Input Invalid Input

2. Addition Addition
Invalid Input Invalid Input
0 0 1 1
Subtraction Subtraction
0 0 1 1 Invalid Input Invalid Input

3. Addition Addition
Invalid Input Invalid Input
0 0 2 2
Subtraction Subtraction
0 0 2 2 Invalid Input Invalid Input

4. Addition Addition
Invalid Input Invalid Input
0 0 50 50
Subtraction Subtraction
0 0 50 50 Invalid Input Invalid Input

5. Addition Addition
Invalid Input Invalid Input
0 0 99 99
Subtraction Subtraction
0 0 99 99 Invalid Input Invalid Input

6. Addition Addition
Invalid Input Invalid Input
0 0 100 100
Subtraction Subtraction
0 0 100 100 Invalid Input Invalid Input
7. Addition Addition
Invalid Input Invalid Input
0 0 101 101
Subtraction Subtraction
0 0 101 101 Invalid Input Invalid Input

8. Addition Addition
Invalid Input Invalid Input
1 1 0 0
Subtraction Subtraction
1 1 0 0 Invalid Input Invalid Input

9. Addition Addition
1 1 1 1 2 2 2 2

1 1 1 1 2 2 2 2

Subtraction Subtraction
0 0 0 0

0 0 0 0

10. Addition Addition


1 1 2 2 3 3 3 3

1 1 2 2 3 3 3 3
Subtraction
Subtraction
-1 -1
-1 -1
-1 -1
-1 -1

11. Addition Addition


1 1 50 50 51 51 51 51

1 1 50 50 51 51 51 51
Subtraction
Subtraction
-49 -49
-49 -49
-49 -49
-49 -49

12. Addition Addition


1 1 99 99 100 100 100 100

1 1 99 99 100 100 100 100


Subtraction
Subtraction
-98 -98
-98 -98
-98 -98
-98 -98

13. Addition Addition


1 1 100 100 101 101 101 101

1 1 100 100 101 101 101 101


Subtraction
Subtraction
-99 -99
-99 -99
-99 -99
-99 -99

14. Addition Addition


Invalid Input Invalid Input
1 1 101 101
Subtraction Subtraction
Invalid Input Invalid Input
1 1 101 101

15. Addition Addition


Invalid Input Invalid Input
2 2 0 0
Subtraction Subtraction
2 2 0 0 Invalid Input Invalid Input

16. Addition Addition


2 2 1 1 3 3 3 3

2 2 1 1 3 3 3 3
Subtraction
Subtraction
1 1
1 1
1 1
1 1

17. Addition Addition


2 2 2 2 4 4 4 4

2 2 2 2 4 4 4 4
Subtraction
Subtraction
0 0
0 0
0 0
0 0

18. Addition Addition


2 2 50 50 52 52 52 52

2 2 50 50 52 52 52 52
Subtraction
Subtraction
-48 -48
-48 -48
-48 -48
-48 -48

19. Addition Addition


2 2 99 99 101 101 101 101

2 2 99 99 101 101 101 101


Subtraction
Subtraction
-97 -97
-97 -97
-97 -97
-97 -97

20. Addition Addition


2 2 100 100 102 102 102 102

2 2 100 100 102 102 102 102


Subtraction
Subtraction
-98 -98
-98 -98
-98 -98
-98 -98

21. Addition Addition


Invalid Input Invalid Input
2 2 101 101
Subtraction Subtraction
Invalid Input Invalid Input
2 2 101 101

22. Addition Addition


Invalid Input Invalid Input
50 50 0 0
Subtraction Subtraction
50 50 0 0 Invalid Input Invalid Input

23. Addition Addition


50 50 1 1 51 51 51 51

50 50 1 1 51 51 51 51
Subtraction
Subtraction
49 49
49 49
49 49
49 49

24. Addition Addition


50 50 2 2 52 52 52 52

50 50 2 2 52 52 52 52
Subtraction
Subtraction
48 48
48 48
48 48
48 48

25. Addition Addition


50 50 50 50 100 100 100 100

50 50 50 50 100 100 100 100


Subtraction
Subtraction
0 0
0 0
0 0
0 0

26. Addition Addition


50 50 99 99 149 149 149 149

50 50 99 99 149 149 149 149


Subtraction
Subtraction
-49 -49
-49 -49
-49 -49
-49 -49

27. Addition Addition


50 50 100 100 150 150 150 150

50 50 100 100 150 150 150 150


Subtraction
Subtraction
-50 -50
-50 -50
-50 -50
-50 -50

28. Addition Addition


Invalid Input Invalid Input
50 50 101 101
Subtraction Subtraction
50 50 101 101 Invalid Input Invalid Input
29. Addition Addition
Invalid Input Invalid Input
99 99 0 0
Subtraction Subtraction
99 99 0 0 Invalid Input Invalid Input

30. Addition Addition


99 99 1 1 100 100 100 100

99 99 1 1 100 100 100 100


Subtraction
Subtraction
98 98
98 98
98 98
98 98

31. Addition Addition


99 99 2 2 101 101 101 101

99 99 2 2 101 101 101 101


Subtraction
Subtraction
97 97
97 97
97 97
97 97

32. Addition Addition


99 99 50 50 149 149 149 149

99 99 50 50 149 149 149 149


Subtraction
Subtraction
49 49
49 49
49 49
49 49

33. Addition Addition


99 99 99 99 198 198 198 198

99 99 99 99 198 198 198 198


Subtraction
Subtraction
0 0
0 0
0 0
0 0

34. Addition Addition


99 99 100 100 199 199 199 199

99 99 100 100 199 199 199 199


Subtraction
Subtraction
-1 -1
-1 -1
-1 -1
-1 -1

35. Addition Addition


Invalid Input Invalid Input
99 99 101 101
Subtraction Subtraction
99 99 101 101 Invalid Input Invalid Input

36. Addition Addition


Invalid Input Invalid Input
100 100 0 0
Subtraction Subtraction
100 100 0 0
Invalid Input Invalid Input
37. Addition Addition
100 100 1 1 101 101 101 101

100 100 1 1 101 101 101 101


Subtraction
Subtraction
99 99
99 99
99 99
99 99

38. Addition Addition


100 100 2 2 102 102 102 102

100 100 2 2 102 102 102 102


Subtraction
Subtraction
98 98
98 98
98 98
98 98

39. Addition Addition


100 100 50 50 150 150 150 150

100 100 50 50 150 150 150 150


Subtraction
Subtraction
50 50
50 50
50 50
50 50

40. Addition Addition


100 100 99 99 199 199 199 199

100 100 99 99 199 199 199 199


Subtraction
Subtraction
1 1
1 1
1 1
1 1

41. Addition Addition


100 100 100 100 200 200 200 200

100 100 100 100 200 200 200 200


Subtraction
Subtraction
0 0
0 0
0 0
0 0

42. Addition Addition


Invalid Input Invalid Input
100 100 101 101
Subtraction Subtraction
100 100 101 101 Invalid Input Invalid Input

43. Addition Addition


Invalid Input Invalid Input
101 101 0 0
Subtraction Subtraction
101 101 0 0 Invalid Input Invalid Input
44. Addition Addition
Invalid Input Invalid Input
101 101 1 1
Subtraction Subtraction
101 101 1 1 Invalid Input Invalid Input

45. Addition Addition


Invalid Input Invalid Input
101 101 2 2
Subtraction Subtraction
101 101 2 2 Invalid Input Invalid Input

46. Addition Addition


Invalid Input Invalid Input
101 101 50 50
Subtraction Subtraction
101 101 50 50 Invalid Input Invalid Input

47. Addition Addition


Invalid Input Invalid Input
101 101 99 99
Subtraction Subtraction
101 101 99 99 Invalid Input Invalid Input

48. Addition Addition


Invalid Input Invalid Input
101 101 100 100
Subtraction Subtraction
101 101 100 100 Invalid Input Invalid Input

49. Addition Addition


Invalid Input Invalid Input
101 101 101 101
Subtraction Subtraction
101 101 101 101 Invalid Input Invalid Input

Since the code was corrected after the Robust Testing Technique, all the actual output comes
out to be the same as all the expected output, hence we see no test case go fail.
EXPERIMENT 7.

Equivalence Testing

Input Domains Test cases = 3^8 => 6561


Suppose the name of variables are -> [a b [e f
c d], g h]
I-1 = {1<=a<=100, 1<=b<=100, ………,1<=h<=100} [all variables are valid]
I-2= {a<1, 1<=b<=100, 1<=c<=100, 1<=d<=100,......,1<=h<=100} [one variable(a)
is invalid]
I-3 to I-9 [only one valuable invalid]
I-4 = {a<1, b<1, 1<=c<=100, 1<=d<=100,......,1<=h<=100} [two variables invalid]
I-5 to I-60 [Test cases when two variables invalid]
I-61= {a<1, b<1, c<1, 1<=d<=100, 1<=e<=100,......,1<=h<=100} [ three variables
invalid]
I-62 to I-658= [Test cases when three variables are invalid]
.
.
I-6561={a<1,b<1,c<1,d<1,e<1….h<1} [ All are invalid]
Test Case ID Test Cases Expected Output Actual Output
Matrix 1 Matrix 2
I1. Addition Addition
Invalid Input
0 50 50 50 50 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
–50 0

0 0

I2. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 50 50 101 Invalid Input
100 151
Subtraction
0 0

0 -51
I3. Addition Addition
Invalid Input
50 0 50 50 100 50
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
0 -50

0 0

I4. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
101 50 50 50 Invalid Input
151 100
Subtraction
0 0

51 0

I5. Addition Addition


Invalid Input
50 50 50 50 100 100
Subtraction
50 101 50 50 Invalid Input
100 151
Subtraction
0 0

0 51

I6. Addition Addition


Invalid Input
50 50 0 50 50 100
Subtraction
50 50 50 50 Invalid Input
100 100
Subtraction
50 0

0 0

Output Domains
O-1={<a,b,c,d,e,f,g,h>: All valid variables gives valid addition, subtraction}
O-2={<a,b,c,d,e,f,g,h>: Invalid inputs}

O1. Addition Addition


1 50 2 99 3 149 3 149

99 100 100 50 199 150 199 150


Subtraction
Subtraction
-1 -49
-1 -49
-1 50
-1 50

O2. Addition Addition


Invalid Input Invalid Input
100 100 101 101
Subtraction Subtraction
0 100 101 101
Invalid Input Invalid Input

EXPERIMENT 8.

Decision Table Based Testing

Decision tables are used in various engineering fields to represent complex logical
relationships. The output may be dependent on many input conditions and decision tables
give a tabular view of various combinations of input conditions and these conditions are in
the form of True(T) and False(F).

R1 R2 R R4 R R6 R7 R8 R9 R10 R11 R1 R R R R R17


3 5 2 1 1 1 1
3 4 5 6

a<1? F T T T T T T T T T T T T T T T T

CONDITION

b<1? - F T T T T T T T T T T T T T T T

c<1? - - F T T T T T T T T T T T T T T

d<1? - - - F T T T T T T T T T T T T T

e<1? - - - - F T T T T T T T T T T T T

f<1? - - - - - F T T T T T T T T T T T

g<1? - - - - - - F T T T T T T T T T T

h<1? - - - - - - - F T T T T T T T T T

a>100? - - - - - - - - F T T T T T T T T

b>100? - - - - - - - - - F T T T T T T T

c>100? - - - - - - - - - - F T T T T T T

d>100? - - - - - - - - - - - F T T T T T

e>100? - - - - - - - - - - - - F T T T T

f>100? - - - - - - - - - - - - - F T T T

g>100? - - - - - - - - - - - - - - F T T

h>100? - - - - - - - - - - - - - - F T

Rule 32 16 8 4 2 1 51 256 128 64 32 16 8 4 2 1 1


Count 76 38 1 0 0 0 2
8 4 9 9 4 2
2 6 8 4

Invalid X X X X X X X X X X X X X X X X
Input
ACTION
Valid X
Input

EXPERIMENT 9.

Control Flow Testing

Control flow testing is a software testing technique that focuses on evaluating the correctness of a
program's control flow structures. It involves designing test cases to explore different paths through
the program, including loops, branches, and decision points. The goal is to ensure that the program
executes as expected under various conditions, uncovering potential errors in control flow logic.

Control Flow Testing Example:


For this code, we can design test cases to cover different scenarios:
1. Test with a positive integer.
2. Test with zero.
3. Test with a negative integer.
Output:

1. Entering 5 should print the factorial of 5.


2. Entering 0 should print the factorial of 0.
3. Entering -3 should print a message asking for a non-negative integer.

Performing control flow testing involves ensuring that each branch and decision point in the
code is exercised by at least one test case. The goal is to verify that the program follows the
intended control flow under various inputs, revealing any potential issues in the logic.

Test Case 1: Positive Integer

Test Case 2: Zero

Test Case 3: Negative Integer

These examples cover the control flow of the program, including the conditional statements and the
recursive function. The goal of control flow testing is to ensure that the program behaves correctly for
different inputs and follows the intended control flow.
EXPERIMENT 10.

DATA FLOW TESTING


Data flow testing is a type of testing that focuses on the paths that data takes through a program.
The goal is to ensure that the program processes data correctly and that data is appropriately
handled throughout its flow. Let's consider a simple example to illustrate data flow testing.

EXAMPLE:-

A program that takes user input for a triangle's three sides and determines whether it is an
equilateral, isosceles, or scalene triangle.

C++ code for the triangle classification program:

#include <iostream>

#include <cmath>

using namespace std;

string classifyTriangle(double a, double b, double c) {

if (a <= 0 || b <= 0 || c <= 0) {

return "Invalid input. Please enter positive values for the sides.";

if (a == b && b == c) {

return "Equilateral";

} else if (a == b || b == c || a == c) {

return "Isosceles";

} else {

return "Scalene";

int main() {

double side_a, side_b, side_c;

// User input

cout << "Enter the length of side a: ";

cin >> side_a;

cout << "Enter the length of side b: ";

cin >> side_b;


cout << "Enter the length of side c: ";

cin >> side_c;

// Classify the triangle and print the result

string result = classifyTriangle(side_a, side_b, side_c);

cout << "The triangle is " << result << "." << endl;

return 0;

Now, let's identify the data flow in this program:

1. User Input (Data Source):

Data enters the program when the user provides input for the lengths of sides a, b, and c.

2. Data Processing:

The program processes the input data by calling the classify_triangle function, which determines
the type of triangle based on the input.

3. Data Output (Result):

The result is the type of triangle (Equilateral, Isosceles, or Scalene), and it is printed to the console.

Test cases for data flow testing:

Test Case 1 (Equilateral Triangle):

Input: a = 5, b = 5, c = 5

Expected Output: "The triangle is Equilateral."

Test Case 2 (Isosceles Triangle):

Input: a = 5, b = 5, c = 6

Expected Output: "The triangle is Isosceles."

Test Case 3 (Scalene Triangle):

Input: a = 3, b = 4, c = 5

Expected Output: "The triangle is Scalene."

Test Case 4 (Invalid Input):

Input: a = -1, b = 2, c = 3

Expected Output: "Invalid input. Please enter positive values for the sides."
EXPERIMENT 11.

Regression Testing
Modification Algorithm

Regression testing is a black box testing techniques. It is used to authenticate a code change
in the software does not impact the existing functionality of the product. Modification
Algorithm is used to minimize and prioritize test cases based on the modified lines of source
code.
#include<bits/stdc++.h>
using namespace std;

int main() {
int t1[50][50];
int count = 0;
int candidate[50] = {0}, priority[50] = {0}, m = 0, pos[50],
found[50][50], k, t, c[50], l, num, n, index[50], i, j, modnum, nfound[50],
mod[50];

cout<<"Enter the number of test cases:";


cin>>num;

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


cout << "\nEnter the length of test case" << i + 1 << ":";
cin >> c[i];
}

for (i = 0; i < 50; i++)


for (j = 0; j < 50; j++)
found[i][j] = 0;

for (i = 0; i < num; i++)


for (j = 0; j < c[i]; j++)
t1[i][j] = 0;

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


cout << "Enter the values of test case " << i + 1 << "\n";
for (j = 0; j < c[i]; j++)
cin>>t1[i][j];
pos[i] = i;
}

cout << "\nEnter number of modified lines of code:";


cin >> modnum;

cout << "Enter the lines of code modified:";


for (i = 0; i < modnum; i++)
cin >> mod[i];

while (1) {
count = 0;
for (i = 0; i < num; i++) {
nfound[i] = 0;
pos[i] = i;
}
for (i = 0; i < num; i++) {
l = 0;
for (j = 0; j < c[i]; j++) {
if (candidate[i] != 1) {
for (k = 0; k < modnum; k++) {
if (t1[i][j] == mod[k]) {
nfound[i]++;
found[i][l] = mod[k];
l++;
}
}
}
}
}
l = 0;
for (i = 0; i < num; i++)
for (j = 0; j < num - 1; j++)
if (nfound[i] > nfound[j]) {
t = nfound[i];
nfound[i] = nfound[j];
nfound[j] = t;
t = pos[i];
pos[i] = pos[j];
pos[j] = t;
}
for (i = 0; i < num; i++)
if (nfound[i] > 0)
count++;
if (count == 0)
break;
candidate[pos[0]] = 1;
priority[pos[0]] = ++m;
cout << "\nTestcase\tMatches";
for (i = 0; i < num; i++)
cout << "\n" << pos[i] + 1 << "\t\t" << nfound[i];
for (i = 0; i < c[pos[0]]; i++)
for (j = 0; j < modnum; j++)
if (t1[pos[0]][i] == mod[j])
mod[j] = 0;
cout << "\nModified Array:";
for (i = 0; i < modnum; i++)
if (mod[i] == 0)
continue;
else
cout << setw(4) << mod[i];
}
count = 0;
cout << "\nTest case selected.....\n";
for (i = 0; i < num; i++)
if (candidate[i] == 1)
cout << "\nT" << i + 1 << "\t Priority" << priority[i] << "\n ";
if (count == 0)
cout << "\nNone";
return 0;
}

Inputs:
Outputs:
Experiment – 12
Regression Testing
Deletion Algorithm
The ‘deletion’ portion of the technique is used to (i) update the execution history of test cases
by removing the deleted lines of source code (ii) identify and remove those test cases that
cover only those lines which are covered by other test cases of the program.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t1[50][50];
int count=0;
int
candidate[50]={0},priority[50]={0},m=0,pos[50],found[50][50],k,t,c[50],l,num,n,index[50],i,j,modnum,nfound
[50],mod[50];
cout<<"Enter the number of test cases:";
cin>>num;
for(i=0;i<num;i++)
{
cout<<"Enter the length of test case"<<i+1<<" : ";
cin>>c[i];
}
for(i=0;i<50;i++)
for(j=0;j<50;j++)
found[i][j]=0;

for(i=0;i<num;i++)
for(j=0;j<c[i];j++){
t1[i][j]=0;
}

for(i=0;i<num;i++){
cout<<"Enter the values of test case "<<i+1<<" : ";
for(j=0;j<c[i];j++){
cin>>t1[i][j];
}
pos[i]=i;
}
cout<<"\nEnter number of modified lines of code: ";
cin>>modnum;
cout<<"Enter the lines of code modified: ";
for(i=0;i<modnum;i++)
cin>>mod[i];

while(1)
{
count=0;
for(i=0;i<num;i++)
{
nfound[i]=0;
pos[i]=i;
}
for(i=0;i<num;i++)
{
l=0;
for(j=0;j<c[i];j++)
{
if(candidate[i]!=1)
{
for(k=0;k<modnum;k++)
{
if(t1[i][j]==mod[k])
{
nfound[i]++;
found[i][l]=mod[k];
l++;
}
}
}
}
}
l=0;
for(i=0;i<num;i++)
for(j=0;j<num-1;j++)
if(nfound[i]>nfound[j])
{
t=nfound[i];
nfound[i]=nfound[j];
nfound[j]=t;
t=pos[i];
pos[i]=pos[j];
pos[j]=t;
}
for(i=0;i<num;i++)
if(nfound[i]>0)
count++;
if(count==0)
break;
candidate[pos[0]]=1;
priority[pos[0]]=++m;
cout<<"\nTestcase\tMatches";
for(i=0;i<num;i++)
{
cout<<"\n"<<pos[i]+1<<"\t\t"<<nfound[i];
}
for(i=0;i<c[pos[0]];i++)
for(j=0;j<modnum;j++)
if(t1[pos[0]][i]==mod[j]){
mod[j]=0;
}
cout<<"\nModified Array:";
for(i=0;i<modnum;i++){
if(mod[i]==0){
continue;
}
else {
cout<<mod[i]<<"\t";
}
}
}
count=0;
cout<<"\nTest case selected.....\n";
for(i=0;i<num;i++)
if(candidate[i]==1){
cout<<"\nT"<<i+1<<"\tPriority"<<priority[i]<<"\n";
count++;
}
if(count==0){
cout<<"\nNone";
}
return 0;
}

OUTPUT

You might also like