ST Lab Manual
ST Lab Manual
Laboratory Manual
SOFTWARE TESTING
For
As you may be aware that MGM has already been awarded with ISO
9001:2015 certification and it is our endure to technically equip our students
taking the advantage of the procedural aspects of ISO 9001:2015
Certification.
Faculty members are also advised that covering these aspects in initial stage
itself, will greatly relieved them in future as much of the load will be taken
care by the enthusiasm energies of the students once they are conceptually
clear.
Dr. H.H.Shinde
Principal
LABORATORY MANUAL CONTENTS
Students are advised to thoroughly go though this manual rather than only
topics mentioned in the syllabus as practical aspects are the key to
understanding and conceptual visualization of theoretical aspects covered in
the books.
1. Make entry in the Log Book as soon as you enter the Laboratory.
2. All the students should sit according to their roll numbers starting from their
left to right.
3. All the students are supposed to enter the terminal number in the log book.
5. All the students are expected to get at least the algorithm of the
program/concept to be implemented.
1. Submission related to whatever lab work has been completed should be done
during the next lab session. The immediate arrangements for printouts related to
submission on the day of practical assignments.
2. Students should be taught for taking the printouts under the observation of lab
teacher.
2 Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of data flow testing, derive at least
10 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 NextDate
problem. Analyze it from the perspective of decision table-based testing, derive at least
10 different test cases, execute these test cases and discuss the test results.
4 Design, develop, code and run the program in any suitable object-oriented language to
solve the calendar problem. Analyze it from the perspective of OO testing, derive test
cases to test the method that increment the date and the method that increments the
month., execute these test cases and discuss the test results.
5 Design, develop, code and run the program in any suitable object-oriented language to
solve the currency converter problem. Analyze it from the perspective of use case-based
system testing, derive appropriate system 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 an
absolute letter grading procedure, making suitable assumptions. Determine the basis
paths and using them derive different test cases, execute these test cases and discuss the
test results
.
7 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.
Experiment 1
Study of Manual and Automated Testing.
Testing of software can be done in both Automation and Manual testing method, but it’s totally
depends on the project requirement, budget associated with the project, and which testing
method will be benefited to the project. This article provides basic information about Manual
Testing and Automation Testing, enjoy reading it and let us know in the comment about which
one is best for your project.
Automation Testing:
The method takes automation tool support to execute the test cases is known as Automation
Testing. Automated testing is good for large project.
It is a method which uses automation tools to run tests that repeat predefined actions, matches
the developed program’s probable and real results. If the project prospects and results align,
your project is behaving as it should, and you are likely bug free. If the two don’t align, still,
there is a problem that requires to be addressed. You’ll have to take a look at your code, alter
it, and continue to run tests until the actual and expected outcomes align.
Manual Testing:
Manual testing is a method used by software developers to run tests manually.
There are many manual testing types which are carried out manually as well as automatically.
These are,
Black Box Testing – It is a testing method to test functionalities and requirements of the system.
It does not test the internal part of the system.
White Box Testing – It is a testing method based on information of the internal logic of an
application’s code and also known as Glass box Testing. It works on Internal working code of
the system. Tests are based on coverage of code statements, branches, paths, conditions.
Integration Testing – Integrated modules testing method to verify joint functionality after
integration. Modules are typically code modules, individual applications, client and server
applications on a network, etc. This type of testing is especially applicable to client/server and
distributed systems.
Automation testing perform the same operation Manual testing is not reliable. Using this
each time method test execution is not accurate all the
time.
Automation testing is very much helpful To execute the test cases first time using manual
regressions in testing where code changes testing will be very much useful. But it is not
frequently. sure that it will catch the regression defects
under frequently changing requirements.
Automation testing will be useful to execute Manual testing will be useful when the test case
the set of test cases frequently. only needs to run once or twice.
After making Automation test suites, fewer To execute the test cases every time tester
testers required to execute the test cases. requires the same amount of time.
Automation testing can also be done on Using manual testing,testing on different
different machine with different OS platform machine with different OS platform
combination, concurrently. combination is not possible, concurrently. To
execute such task different testers are required.
Using Automation testing, testers can test It does not involve in programming task to fetch
complicated application too. hidden information.
Automation runs test cases significantly faster Manual testing is slower than automation.
than human resources. Running tests manually can be very time
consuming.
Some time it is not helpful in UI testing It is very much helpful in UI testing
Automation testing is very useful for To execute the Build Verification Testing
automating the Build Verification Testing (BVT) is very mundane and tiresome in manual
(BVT) & it is not mundane and tiresome. testing.
Initial cost of automation testing is more than Manual testing requires less cost than
manual testing but useful always. automation.
Experiment 2
Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of data flow testing, derive
at least 10 different test cases, execute these test cases and discuss the test results.
(16,21) <16-17-18-19-14- NO
21>
<16-17-18-19-20-
(16,24) 14-21-22-23-24> NO
(17,22) <17-18-19-20-14- NO
21-22>
<17-18-19-20-14-
(17,25) 21-22-23-24- NO
25>
else
}
return 0;
int isleap(int year)
{
if((year%4==0 && year%100!=0) || year%400==0) return 1;
else
}
return 0;
int main()
{
int day,month,year,tomm_day,tomm_month,tomm_year; char flag;
do
{
flag='y';
printf("\nEnter the today's date in the form of dd mm yyyy\n");
scanf("%d%d%d",&day,&month,&year); tomm_month=month;
tomm_year= year; if(day<1 || day>31)
{
printf("value of day, not in the range 1...31\n");
flag='n';
}
if(month<1 || month>12)
{
printf("value of month, not in the range 1. .. 12\n"); flag='n';
}
else if(check(day,month))
{
printf("value of day, not in the range day<=30"); flag='n';
}
if(year<1812 || year>=2013)
{
else
{
}
tomm_day=1; tomm_month=month+1;
break; case 4:
case 6:
case 9:
case 11: if(day<30)
tomm_day=day+1;
else
{
}
tomm_day=1; tomm_month=month+1;
break;
case 12: if(day<31)
tomm_day=day+1;
else
{
tomm_day=1; tomm_month=1; if(year==2013)
{
printf("\nThe next day is out of boundary value of year\n"); tomm_year=year+1;
}
else
tomm_year=year+1;
}
break; case 2:
if(day<28)
tomm_day=day+1;
else if(isleap(year)&& day==28)
tomm_day=day+1; else if(day==28 || day==29)
{
tomm_day=1; tomm_month=3;
}
break;
}
printf("\nNext day is : %d %d %d\n",tomm_day,tomm_month,tomm_year); return 0;
}
NextDate problem Input Data Decision Table
RULES R1 R2 R3 R4 R5
F T T T T
Conditions
Actions
4
Experiment 4
Design, develop, code and run the program in any suitable object-oriented language
to solve the calendar problem. Analyze it from the perspective of OO testing, derive
test cases to test the method that increment the date and the method that
increments the month., execute these test cases and discuss the test results.
Example: ooNextDate
Very little documentation is required by UML at the unit/class level. Here, we add the class
responsibility collaboration (CRC) cards for each class, followed by the class pseudocode,
and then the program graphs for the class operations (see Figures ). CRC cards are not
formally part of UML.
program graphs for testIt and Date classes.
Methods as Units
Superficially, this choice reduces object-oriented unit testing to traditional (procedural) unit
testing. A method is nearly equivalent to a procedure, so all the traditional specification-based
and code-based testing techniques apply. Unit testing of procedural code requires stubs and a
driver test program to supply test cases and record results. Mock objects are the object-oriented
analogue of this practice. Since instances of the nUnit framework are available for most object-
oriented languages, the assert mechanism in those frameworks is the most convenient choice.
When we look more closely at individual methods, we see the happy consequence of
encapsulation: they are generally simple. The pseudocode and corresponding program graphs
for the classes that make up the ooCalendar application are in Section Notice that the
cyclomatic complexities of the various operations are uniformly low. Date.increment has the
highest cyclomatic complexity, and it is only V(G) = 3. To be fair, this implementation is
intentionally simple—no checking is necessary for valid inputs. With validity checking, the
cyclomatic complexities would increase. As we saw in Chapter 6, equivalence class testing is
a good choice for logic-intensive units. The Date.increment operation treats the three
equivalence classes of days:
D1 = {day: 1 < = day < last day of the month}
D2 = {day: day is the last day of a non-December month}
D3 = {day: day is December 31}
At first, these equivalence classes appear to be loosely defined, especially D1, with its reference
to the unspecified last day of the month and no reference to which month. Thanks to
encapsulation, we can ignore these questions. (Actually, the questions are transferred to the
testing of the Month.increment operation.) Even though the cyclomatic complexity is low, the
interface complexity is quite high. Looking at Date.increment again, notice the intense
messaging: messages are sent to two operations in the Day class, to one operation in the Year
class, and to two operations in the Month class. This means that nearly as much effort will be
made to create the proper stubs as in identifying test cases. Another more important
consequence is that much of the burden is shifted to integration testing. In fact, we can identify
two levels of integration testing: intraclass and interclass integration.
Classes as Units
Treating a class as a unit solves the intraclass integration problem, but it creates other problems.
One has to do with various views of a class. In the static view, a class exists as source code.
This is fine if all we do is code reading. The problem with the static view is that inheritance is
ignored, but we can fix this by using fully flattened classes. We might call the second view the
compile-time view because this is when the inheritance actually “occurs.” The third view is the
execution-time view, when objects of classes are instantiated. Testing really occurs with the
third view, but we still have some problems. For example, we cannot test abstract classes
because they cannot be instantiated. Also, if we are using fully flattened classes, we will need
to “unflatten” them to their original form when our unit testing is complete. If we do not use
fully flattened classes, in order to compile a class, we will need all the other classes above it in
the inheritance tree. One can imagine the software configuration management implications of
this requirement. The class-as-unit choice makes the most sense when little inheritance occurs,
and classes have what we might call internal control complexity. The class itself should have
an “interesting” (mildly complex, nontrivial) StateChart, and there should be a fair amount of
internal messaging. To explore class-as-unit testing, we will revisit the windshield wiper
example with a more complex version
Experiment 5
Design, develop, code and run the program in any suitable object-oriented
language to solve the currency converter problem. Analyze it from the
perspective of use case-based system testing, derive appropriate system test
cases, execute these test cases and discuss the test results.
The currency converter application converts U.S. dollars to any of four currencies: Brazilian
reals, Canadian dollars, European Community euros, and Japanese yen. The user can revise
inputs and perform repeated currency conversion
In the first step, sometimes called project inception, the customer/user describes the application
in very general terms. This might take the form of “user stories,” which are precursors to use
cases. From these, three types of system functions are identified: evident, hidden, and frill.
Evident functions are the obvious ones. Hidden functions might not be discovered immediately,
and frills are the “bells and whistles” that so often occur. Table lists the system functions for
the currency converter application
System Functions for Currency Converter application
Reference No Function Category
R1 Start application Evident
R2 End application Evident
R3 Input US dollar amount Evident
R4 R4 Select country Evident
R5 Perform conversion calculation Evident
R6 Clear user inputs and program outputs Evident Evident
R7 Maintain exclusive–or relationship among Hidden
countries
. R8 Display country flag images . Frill
The use case development begins with a very high-level view. Notice, as the succeeding levels
of use cases are elaborated, much of the early information is retained. It is convenient to have
a short, structured naming convention for the various levels of use cases. Here, for example,
HLUC refers to high-level use case (where would we be without acronyms?). Very few details
are provided in a high-level use case; they are insufficient for test case identification. The main
point of high-level use cases is that they capture a narrative description of something that
happens in the system to be built
HLUC 1 Start application.
Description The user starts the currency conversion application in
Windows®.
int main()
{
float per; char grade;
1. scanf("%f",&per); 2. if(per>=90)
3. grade= 'A';
4. else if(per>=80 && per<90)
5. grade ='B';
6. else if(per>=70 && per<80)
7. grade ='C';
8. else if(per>=60 && per<70)
9. grade='D';
10. else grade='E';
11. switch(grade)
12. {
13. case 'A': printf("\nEXCELLENT"); break;
14. case 'B':printf("\nVery Good"); break;
15. case 'C' : printf("\nGood"); break;
16. case 'D': printf("\nAbove Average"); break;
17. case 'E': printf("\n Satisfactory"); break;
18. }
19. printf("\t The percentage = %f and grade is %c ",per,grade);
20. return 0;
}
Independent Paths
#Edges=25, #Nodes=18, #P=1
V(G)= E-N+2P = 25-18+2 = 09
P1: 1-2-4-6-8-10-11-17-19-20 E Grade
P2: 1-2-4-6-8-9-11-16-19-20 D Grade
P3: 1-2-4-6-7-11-15-19-20 C Grade
P4: 1-2-4-5-11-14-19-20 B Grade
P5: 1-2-3-11-13-19-20 A Grade
P6: 1-2-4-6-8-10-11-13-19-20
P7: 1-2-4-6-8-10-11-14-19-20
P8: 1-2-4-6-8-10-11-15-19-20
P9: 1-2-4-6-8-10-11-16-19-20
Program Graph
Pre-Conditions/Issues:
Percentage Per is a positive Float Number
#include<stdio.h>
int binary(int x[],int low,int high,int key)
{
int mid; while(low<=high)
{
mid=(low+high)/2; if(x[mid]==key) return mid; if(x[mid]<key) low=mid+1;
else high=mid-1;
}
return -1;
}
int main()
{
int a[20], key,i,n,succ; printf("Enter the n value"); scanf("%d",&n);
if(n>0)
{
printf("enter the elements in ascending order"); for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter the element to be searched"); scanf("%d",&key);
succ=binary(a,0,n-1,key); if(succ>=0)
printf("element found at %d location",succ+1); else
printf("element not found");
}
else
printf("number of elements should be greater than 0"); return 0;
}
Preconditions/ Issues:
Array has elements in Ascending order T/F
Key element is in the array T/F
Array has ODD number of elements T/F
Test Cases – Binary Search
Paths Inputs Expected Remarks
X[] Key Output
P1: 1-2-3-8-9 {10,20,30,40,5 30 Success Key є X[] and
0} Key==X[mid]