STQA Lab Manual
STQA Lab Manual
PRACTICAL: 01
Theory: -
Boundary Value Analysis (BVA) is a Black-Box testing
technique used to check the errors at the boundaries of an input
domain.
Steps: -
1. Identify the boundaries.
2. Create valid and invalid partitions based on boundary values.
3. Create test cases for valid and invalid partitions.
Execution: -
First Example
Let's consider an example where we need to test a function that
processes age input, which is valid for ages between 18 and 65
(inclusive).
Valid
Invalid Invalid
(min, min + 1, max – 1,
(min – 1) (max + 1)
max)
Second Example
Assume the valid password length is between 8 and 20
characters (inclusive).
Valid
Invalid Invalid
(min, min + 1, max – 1,
(min – 1) (max + 1)
max)
7 8, 9, 19, 20 21
Third Example
Assume the passing marks are between 40 and 100 (inclusive).
Valid
Invalid Invalid
(min, min + 1, max – 1,
(min – 1) (max + 1)
max)
Forth Example
Assume the valid name length is between 3 and 50 characters
(inclusive).
Valid
Invalid Invalid
(min, min + 1, max – 1,
(min – 1) (max + 1)
max)
2 3, 4, 49, 50 51
Fifth Example
Assume the valid amount is between ₹100 and ₹5000
(inclusive).
Valid
Invalid Invalid
(min, min + 1, max – 1,
(min – 1) (max + 1)
max)
PRACTICAL: 02
Theory: -
Equivalence class partitioning is black box testing
technique that divides the input data of a software unit into
partitions of equivalent data from which test cases can be
derived. Here test cases are designed to cover each
partition at least once.
Case: -
1. If the range condition is given as an input, then one valid and
two invalid equivalence classes are defined.
Execution: -
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Page| 5
Div: 25(CSE)
Faculty of Engineering & Technology
Software Testing and Quality Assurance (203105396)
B. Tech CSE 4th Year 7th Semester
Teenager: 13 – 17 years
Valid Invalid
(any number ending with a 0) (any number not ending with a 0)
10, 20, 30… 38, 95, 17, etc.
Valid Invalid
(true/1 OR false/0; based on your statement) (true/1 OR false/0; based on your statement)
True/1 based on the given statement False/0 based on the given statement
PRACTICAL: 03
Theory: -
Cyclomatic complexity of a code section is the quantitative
measure of the number of linearly independent paths in it.
It is a software metric useful for structured or White box
testing.
Mathematically, for a structured program, the directed graph
inside control flow is the edge joining two basic blocks of the
program as control may pass from first to second.
So, cyclomatic complexity M would be defined as,
M=E–N+2
E = the number of edges in the control flow graph
N = the number of nodes in the control flow graph
Code: -
#include <stdio.h>
int isLeapYear(int year) {
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) {
return 1;
} else {
return 0;
}
} else {
return 1;
}
} else {
return 0;
}
}
int main() {
int year, month, days;
int monthDays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Page| 8
Div: 25(CSE)
Faculty of Engineering & Technology
Software Testing and Quality Assurance (203105396)
B. Tech CSE 4th Year 7th Semester
31};
printf("Enter year: ");
scanf("%d", &year);
printf("Enter month (1-12): ");
scanf("%d", &month);
if (month < 1 || month > 12) {
printf("Invalid month. Please enter a value between 1 and
12.\n");
return 1;
}
if (month == 2 && isLeapYear(year)) {
days = 29;
} else {
days = monthDays[month 1];
}
printf("Number of days in month %d of year %d is: %d\n",
month, year, days);
return 0;
}
Method 1:
Edge nodes + 2 => 34 30 + 2 = 6
Method 2:
Predicate nodes +1 = 5+1 = 6 (6,7,10,17,20 are predicate nodes)
Method 3:
Total regions = 6
(Here r1, r2, r3, r4, r5 & r6 are the all regions)
V(G) = 6 and is same by all the three methods.
Identification of Independent paths (Basic Path set) from the
control flow graph:
1) 1-6-7-8-9-10-11-12-16-26-30
2) 1-6-7-8-9-10-13-15-16-26-30
3) 1-6-7-17-18-19-26-30
4) 1-6-7-17-20-21-22-26-30
5) 1-6-7-17-20-23-24-26-30
6) 1-6-27-28-29-30
PRACTICAL: 05
PRACTICAL: 04
Decision Table: -
Valid Cases: -
1. Case 5: The user inserts a valid card, enters a valid PIN, has
sufficient balance, the card is not rejected, does not need to
re-enter the PIN, and the ATM dispenses cash.
Invalid Cases: -
1. Case 1: The user inserts an invalid card, the card is rejected,
does not need to re-enter the PIN, and the ATM does not
dispense cash.
3. Case 3: The user inserts a valid card, enters a valid PIN, has
three invalid PIN attempts, no balance info, the card is not
rejected, does not need to re-enter the PIN, and the ATM
does not dispense cash.
4. Case 4: The user inserts a valid card, enters a valid PIN, has
fewer than three invalid PIN attempts, insufficient balance,
the card is not rejected, does not need to re-enter the PIN, and
the ATM does not dispense cash.
PRACTICAL: 06
Theory: -
1. Selenium
Functions and Features:
Used for web application testing.
Supports multiple browsers (Chrome, Firefox, Safari, etc.).
Compatible with various platforms (Windows, Mac,
Linux).
Integrates with several programming languages (Java, C#,
Python, Ruby, etc.).
Provides Selenium WebDriver for browser automation.
Advantages:
Open-source and free to use.
Wide community support and extensive documentation.
Supports parallel test execution.
Easily integrates with other tools (e.g., TestNG, JUnit).
Disadvantages:
Requires programming skills.
Limited support for handling complex web elements.
Initial setup and configuration can be time-consuming.
Usage:
Ideal for regression testing and cross-browser testing.
Widely used in continuous integration/continuous delivery
(CI/CD) pipelines.
2. JUnit
Functions and Features:
Primarily used for Java applications.
Provides annotations to identify test methods.
Supports assertions to check expected results.
Integrates well with build tools like Maven and Gradle.
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
P a g e | 15
Div: 25(CSE)
Faculty of Engineering & Technology
Software Testing and Quality Assurance (203105396)
B. Tech CSE 4th Year 7th Semester
Advantages:
Simple and easy to use.
Well suited for unit testing.
Facilitates test driven development (TDD).
Disadvantages:
Limited to Java applications.
Not suitable for testing non-Java applications.
Usage:
Best for unit testing and small-scale integration testing in
Java projects.
3. TestNG
Functions and Features:
Inspired by JUnit but offers more flexibility and features.
Supports parallel testing and data driven testing.
Provides detailed test reports and logs.
Integrates well with Selenium and Jenkins.
Advantages:
Powerful and flexible testing framework.
Supports a wide range of test configurations.
Enhances test organization with groups and dependencies.
Disadvantages:
Requires more configuration compared to JUnit.
Has a steeper learning curve for beginners.
Usage:
Suitable for complex test scenarios and large-scale testing
projects.
Often used in combination with Selenium for web
application testing.
4. Cucumber
Advantages:
Promotes collaboration between technical and non-
technical team members.
Enhances readability and maintainability of test cases.
Supports reusable step definitions.
Disadvantages:
Requires additional effort to write Gherkin scenarios.
Slower execution compared to traditional test scripts.
Usage:
Ideal for BDD projects where collaboration and
communication are key.
Suitable for web and mobile application testing.
5. Appium
Functions and Features:
Used for mobile application testing on iOS and Android.
Supports native, hybrid, and mobile web applications.
Based on Selenium WebDriver, providing similar features.
Advantages:
Open source and free to use.
Supports multiple programming languages.
Can automate any mobile app from any language.
Disadvantages:
Complex setup and configuration.
Performance issues with large test suites.
Usage:
6. Jenkins
Functions and Features:
An open-source automation server for CI/CD.
Provides numerous plugins for integration with various
tools.
Automates the build, test, and deployment processes.
Advantages:
Highly extensible with a large plugin ecosystem.
Supports distributed builds for better performance.
Facilitates continuous integration and delivery.
Disadvantages:
Can be resource intensive.
Requires proper configuration and maintenance.
Usage:
Widely used in CI/CD pipelines to automate testing and
deployment.
Integrates with tools like Selenium, JUnit, TestNG, and
more.
7. Katalon Studio
Functions and Features:
An all-in-one test automation solution.
Supports web, API, mobile, and desktop application
testing.
Provides a user-friendly interface and built in keywords
for test creation.
Advantages:
Easy to use, even for beginners.
Comprehensive reporting and analytics.
Integrates with CI/CD tools like Jenkins and Azure
DevOps.
Disadvantages:
Limited customization options compared to coding-based
frameworks.
Performance issues with very large test suites.
Usage:
Ideal for teams looking for an out of the box solution.
Suitable for a wide range of application testing needs.
8. Postman
Functions and Features:
Widely used for API testing.
Offers a user-friendly interface for designing, testing, and
documenting APIs.
Supports automated testing with Postman collections and
Newman CLI.
Advantages:
Simple and intuitive interface.
Facilitates API documentation and sharing.
Extensive community support and documentation.
Disadvantages:
Limited to API testing.
Performance issues with very large collections.
Usage:
Best for API functional and regression testing.
Suitable for developers and testers in API centric projects.
9. SoapUI
Functions and Features:
Used for testing SOAP and RESTful web services.
Offers functional, security, and load testing.
Provides comprehensive test creation and execution
features.
Advantages:
Supports complex and advanced API testing scenarios.
Integrates with CI tools like Jenkins and Azure DevOps.
Extensive support for data driven testing.
Disadvantages:
Can be complex for beginners.
Requires a paid license for the Pro version to access
advanced features.
Usage:
Ideal for comprehensive API testing, including functional,
security, and performance testing.
Suitable for projects with complex API interactions.
10. Robot Framework
Functions and Features:
A generic test automation framework.
Uses keyword driven testing approach.
Supports various external libraries (e.g., Selenium,
Appium).
Advantages:
Highly extensible and flexible.
Supports both functional and acceptance testing.
Encourages reusable and readable test cases.
Disadvantages:
Requires some initial learning to understand the keyword
driven approach.
Performance issues with very large test suites.
Usage:
Suitable for a wide range of applications, including web,
mobile, and desktop.
PRACTICAL: 07
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
{"emp","rb","rd","emp","rd","rd"},
{"emp","rf","rf","emp","rf","rf"}
};
struct gotol
{
char r[3][4];
};
const struct gotol G[12]=
{
{"b","c","d"},
{"emp","emp","emp"},
{"emp","emp","emp"},
{"emp","emp","emp"},
{"i","c","d"},
{"emp","emp","emp"},
{"emp","j","d"},
{"emp","emp","k"},
{"emp","emp","emp"},
{"emp","emp","emp"},
};
char ter[6]={'i','+','*',')','(','$'};
char nter[3]={'E','T','F'};
char states[12]={'a','b','c','d','e','f','g','h','m','j','k','l'};
char stack[100];
int top= 1;
char temp[10];
struct grammar
{
char left;
char right[5];
};
const struct grammar rl[6]=
{
{'E',"e+T"},
{'E',"T"},
{'T',"T*F"},
{'T',"F"},
{'F',"(E)"},
{'F',"i"},
};
void main()
{
char inp[80],x,p,dl[80],y,bl='a';
int i=0,j,k,l,n,m,c,len;
printf(" Enter the input :");
scanf("%s",inp);
len=strlen(inp);
inp[len]='$';
inp[len+1]='\0';
push(stack,&top,bl);
printf("\n stack \t\t\t input");
printt(stack,&top,inp,i);
do
{
x=inp[i];
p=stacktop(stack);
isproduct(x,p);
if(strcmp(temp,"emp")==0)
error();
if(strcmp(temp,"acc")==0)
break;
else
{
if(temp[0]=='s')
{
push(stack,&top,inp[i]);
push(stack,&top,temp[1]);
i++;
}
else
{
if(temp[0]=='r')
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
P a g e | 24
Div: 25(CSE)
Faculty of Engineering & Technology
Software Testing and Quality Assurance (203105396)
B. Tech CSE 4th Year 7th Semester
{
j=isstate(temp[1]);
strcpy(temp,rl[j 2].right);
dl[0]=rl[j 2].left;
dl[1]='\0';
n=strlen(temp);
for(k=0;k<2*n;k++)
pop(stack,&top);
for(m=0;dl[m]!='\0';m++)
push(stack,&top,dl[m]);
l=top;
y=stack[l 1];
isreduce(y,dl[0]);
for(m=0;temp[m]!='\0';m++)
push(stack,&top,temp[m]);
}
}
}
printt(stack,&top,inp,i);
}
while(inp[i]!='\0');
if(strcmp(temp,"acc")==0)
printf(" \n accept the input ");
else
printf(" \n do not accept the input ");
}
void error()
{
printf(" error in the input ");
exit(0);
}
void isreduce(char x,char p)
{
int k,l;
k=isstate(x);
l=isnter(p);
strcpy(temp,G[k 1].r[l 1]);
}
char pop(char *s,int *sp)
{
char item;
if(*sp== 1)
printf(" stack is empty ");
else
{
item=s[*sp];
*sp=*sp 1;
}
return item;
}
void printt(char *t,int *p,char inp[],int i)
{
int r;
printf("\n");
for(r=0;r<=*p;r++)
rep(t,r);
printf("\t\t\t");
for(r=i;inp[r]!='\0';r++)
printf("%c",inp[r]);
}
void rep(char t[],int r)
{
char c;
c=t[r];
switch(c)
{
case 'a': printf("0");
break;
case 'b': printf("1");
break;
case 'c': printf("2");
break;
case 'd': printf("3");
break;
case 'e': printf("4");
break;
case 'f': printf("5");
break;
case 'g': printf("6");
break;
case 'h': printf("7");
break;
case 'm': printf("8");
break;
case 'j': printf("9");
break;
case 'k': printf("10");
break;
case 'l': printf("11");
break;
default :printf("%c",t[r]);
break;
}
}
Output:
PRACTICAL: 08
Explanation:
Lex A Lexical Analyzer Generator:
Lex is a program generator designed for lexical processing
of character input streams. It accepts a high level, problem
oriented specification for character string matching, and
produces a program in a general purpose language which
recognizes regular expressions. The regular expressions
are specified by the user in the source specifications given
to Lex. The Lex written code recognizes these expressions
in an input stream and partitions the input stream into
strings matching the expressions.
What is Flex?
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
P a g e | 30
Div: 25(CSE)
Faculty of Engineering & Technology
Software Testing and Quality Assurance (203105396)
B. Tech CSE 4th Year 7th Semester
Installing Software’s:
1. Download Flex 2.5.4a
2. Download Bison 2.4.1
3. Download DevC++
4. Install Flex at "C:\GnuWin32"
5. Install Bison at "C:\GnuWin32"
6. Install DevC++ at "C:\Dev Cpp"
7. Open Environment Variables.
8. Add "C:\GnuWin32\bin;C:\Dev Cpp\bin;" to path.
bison dy hello.y
gcc lex.yy.c y.tab.c
3. For Executing the Program
a.exe
Code:
EXAMPLE: HELLO.L FILE
%{
#include "y.tab.h"
int yyerror(char *errormsg);
%}
%%
("hi"|"oi")"\n" { return HI; }
("tchau"|"bye")"\n" { return BYE; }
. { yyerror("Unknown char"); }
%%
int main(void)
{
yyparse();
return 0;
}
int yywrap(void)
{
return 0;
}
HELLO.Y FILE
%{
#include <stdio.h>
#include <stdlib.h>
int yylex(void);
int yyerror(const char *s);
%}
%token HI BYE
%%
program:
hi bye
;
hi:
HI { printf("Hello World\n"); }
;
bye:
BYE { printf("Bye World\n"); exit(0); }
;
Output:
PRACTICAL: 09
AIM: Create a Lexer to take input from text file and count no of
characters, no. of lines & no. of words.
Code:
%{
#include<stdio.h>
int lines=0, words=0,s_letters=0,c_letters=0, num=0,
spl_char=0,total=0;
%}
%%
\n { lines++; words++;} [\t ' '] words++;
[A Z] c_letters++;
[a z] s_letters++;
[0 9] num++;
. spl_char++;
%%
main(void)
{
yyin= fopen("practical9.txt","r");
yylex();
total=s_letters+c_letters+num+spl_char;
printf(" This File contains ...");
printf("\n\t%d lines", lines);
printf("\n\t%d words",words);
printf("\n\t%d small letters", s_letters);
printf("\n\t%d capital letters",c_letters);
printf("\n\t%d digits", num);
printf("\n\t%d special characters",spl_char);
printf("\n\tIn total %d characters.\n",total);
}
int yywrap()
{
return(1);
}
Practical9.txt FILE :
Hii
I'm Umang From Cse
Output:
PRACTICAL: 10
Code:
%{
int vow_count=0; int const_count =0;
%}
%%
[aeiouAEIOU] {vow_count++;} [a zA Z] {const_count++;}
%%
main()
{
yyin= fopen("practical8.txt","r"); yylex();
printf("The number of vowels are: %d\n",vow_count);
printf("The number of consonants are: %d\n",const_count);
return 0;
}
yywrap()
{
return 1;}
Practical10.txt FILE
Hii
I'm Umang From Cse
Output:
PRACTICAL: 11
AIM: Write a Lex program to print out all numbers from the
given file.
Code:
%{
#include<stdio.h> int num=0;
%}
%%
[0 9] num++; ECHO;
%%
main(void)
{
yyin= fopen("practical11.txt","r");
yylex();
printf("\n\t%d digits", num);}
int yywrap()
{
return(1);}
Practical11.txt FILE
23332
23
Sbfjehbcc
Output:
PRACTICAL: 12
Code:
%{
#include<stdio.h>
%}
%%
\<[^>]*\> printf("%s\n",yytext);
.|\n;
%%
int yywrap()
{
return 1;
}
int main()
{
yyin=fopen("practical10b.txt","r");
yylex();
return 0;
}
Practical10b.txt FILE
<html>
<body>
<h1> Hello</h1>
<br>
</body>
</html>
Output: