STQA File
STQA File
ON
SOFTWARE TESTING AND QUALITY ASSURANCE
[IT414]
AIM: Design test cases using the boundary value analysis by taking quadratic problem.
SOFTWARE REQUIRED: Borland C/ C++
THEORY: Boundary value analysis is a test case design technique to test boundary value
between partitions (both valid boundary partition and invalid boundary partition). A boundary
value is an input or output value on the border of an equivalence partition, includes minimum
and maximum values at inside and outside boundaries. Normally Boundary value analysis is part
of stress and negative testing.
Using Boundary Value Analysis technique tester creates test cases for required input field. For
example; an Address text box which allows maximum 500 characters. So, writing test cases for
each character once will be very difficult so that will choose boundary value analysis.
Example for Boundary Value Analysis:
Suppose you have very important tool at office, accepts valid User Name and Password field to
work on that tool, and accepts minimum 8 characters and maximum 12 characters. Valid range
8-12, Invalid range 7 or less than 7 and Invalid range 13 or more than 13.
Write Test Cases for Valid partition value, Invalid partition value and exact boundary value.
Problem statement: Consider a program for the determination of nature of roots of a quadratic
equation.
Description: Its input is a triple of positive integers say a,b,c may be from interval 0 to 100. The
program output may have one of the following words: Not a quadratic equation, imaginary roots
and Equal Roots. Design the BV test cases.
PROGRAM:
1. #include<stdio.h>
2. #include<conio.h>
3. #include<math.h>
4. void main()
5. {
6. clrscr();
7. int a,b,c.d;
8. printf(“the quadratic equation is of the type a(x2)+bx+c=0”);
9. printf(“\nenter the value of a:”);
10. scanf(“%d”,%a);
11. printf(“\nenter the value of b:”);
12. scanf(“%d”,%b);
13. printf(“\nenter the value of c:”);
14. scanf(“%d”,%c);
15. d=(b*b)-4*a*c;
16. if((a<0)||(b<0)||(c<0)||(a>100)||(b>100)||(c>100))
17. printf(“\ninvalid input”);
18. else if(a==0)
19. printf(“\n not a quad equation”);
20. else if(d==0)
21. printf(“\nroots are equal”);
22. else if(d<0)
23. printf(“\nimaginary roots”);
24. else
25. printf(“\n real roots”);
26. getch();
27. }
AIM: Design test cases using Equivalence class partitioning taking triangle problem.
SOFTWARE REQUIRED: Turbo C++ Environment.
THEORY: Equivalence partitioning is a Test Case Design Technique to divide the input data of
software into different equivalence data classes. Test cases are designed for equivalence data
class. The equivalence partitions are frequently derived from the requirements specification for
input data that influence the processing of the test object. A use of this method reduces the time
necessary for testing software using less and effective test cases.
Equivalence Partitioning = Equivalence Class Partitioning = ECP
It can be used at any level of software for testing and is preferably a good technique to use first.
In this technique, only one condition to be tested from each partition. Because we assume that,
all the conditions in one partition behave in the same manner by the software. In a partition, if
one condition works other will definitely work. Likewise we assume that, if one of the condition
does not work then none of the conditions in that partition will work.
Equivalence partitioning is a testing technique where input values set into classes for testing.
Example of Equivalence Class Partitioning:
While evaluating Equivalence partitioning, values in all partitions are equivalent that’s why 0-5
are equivalent, 6 – 10 are equivalent and 11- 14 are equivalent.
At the time of testing, test 4 and 12 as invalid values and 7 as valid one.
It is easy to test input ranges 6–10 but harder to test input ranges 2-600. Testing will be easy in
the case of lesser test cases but you should be very careful. Assuming, valid input is 7. That
means, you belief that the developer coded the correct valid range (6-10).
Problem Statement: Consider a program for the determination of Previous date. Its input is a
triple of day, month and year with the values in the range
1 ≤ month ≤ 12
1 ≤ day ≤ 31
2000 ≤ year ≤ 2050
The possible outputs are “Previous date” and “Invalid date”. Design the test cases using decision
table-based testing.
Program:
1. #include<iostream.h>
2. # include<conio.h>
3. int leap(int year);
4. void main()
5. {
6. clrscr();
7. int dc,month,date,year,dm,dn,leap;
8. cout<<“Enter the date”;
9. cin>>date;
10. cout<<“\nEnter the month”;
11. cin>>month;
12. cout<<“\nEnter the year:”;
13. cin>>year;
14. cout<<“\nEntered date is:”<<date<<“/”<<month<<“/”<<year;
15. if(leap==0)
16. {
17. if(month==1)
18. dm=0;
19. if(month==2)
20. dm=31;
21. if(month==3)
22. dm=59;
23. if(month==4)
24. dm=90;
25. if(month==5)
26. dm=120;
27. if(month==6)
28. dm=151;
29. if(month==7)
30. dm=181;
31. if(month==8)
32. dm=212;
33. if(month==9)
34. dm=243;
35. if(month==10)
36. dm=273;
37. if(month==11)
38. dm=304;
39. if(month==12)
40. dm=334;
41. }
42. else
43. {
44. if(month==1)
45. dm=0;
46. if(month==2)
47. dm=31;
48. if(month==3)
49. dm=60;
50. if(month==4)
51. dm=91;
52. if(month==5)
53. dm=121;
54. if(month==6)
55. dm=152;
56. if(month==7)
57. dm=182;
58. if(month==8)
59. dm=213;
60. if(month==9)
61. dm=244;
62. if(month==10)
63. dm=274;
64. if(month==11)
65. dm=305;
66. if(month==12)
67. dm=335;
68. }
69. dc=dm+date;
70. cout<<“The no of Day is:”<<dc;
71. dn=dc%7;
72. if(dn==0)
73. cout<<“\nSaturday”;
74. else if(dn==1)
75. cout<<“\nSunday”;
76. else if(dn==2)
77. cout<<“\nMonday”;
78. else if(dn==3)
79. cout<<“\nTuesday”;
80. else if(dn==4)
81. cout<<“\nWednesday”;
82. else if(dn==5)
83. cout<<“\nThursday”;
84. else if(dn==6)
85. cout<<“\nFriday”;
86. getch();
87. }
88. int leap(int year)
89. {
90. if(((year%100==0) && (year%400==0)) || (year%4==0))
91. {
92. return 1;
93. }
94. else
95. return 0;
96. }
Test Cases:
Output domain equivalence classes are:
O1= {<D, M, Y>: Previous date if all are valid inputs}
O1= {<D, M, Y>: Invalid date if any input makes the date invalid}
Test case M D Y Expected output
We may have another set of test cases which are based on input domain.
I1= {month: 1 ≤ m ≤ 12}
I2= {month: m < 1}
I3= {month: m > 12}
I4= {day: 1 ≤ D ≤ 31}
I5= {day: D < 1}
I6= {day: D > 31}
I7= {year: 1900 ≤ Y ≤ 2050}
I8= {year: Y < 2000}
I9= {year: Y > 2050}
Inputs domain test cases are:
TEST RESULT: The result interprets that the program used conforms to Equivalence Class
Test.
EXPERIMENT-3
AIM: Design test cases using Decision table by taking triangle problem.
SOFTWARE REQUIRED: Borland C/ C++
THEORY: A decision table is a good way to deal with different combination inputs with their
associated outputs and also called cause-effect table. Reason to call cause-effect table is an
associated logical diagramming technique called cause-effect graphing that is basically use to
derive the decision table.
Decision table testing is black box test design technique to determine the test scenarios for
complex business logic.
Example:
Printer troubleshooter
Rules
Printer is unrecognized Y N Y N Y N Y N
Check/replace ink X X X X
Check for paper jam X X
Decision Table:
Conditions-
c1: a,b,c are sides of a triangle?
c2: a=b?
c3: a=c?
c4: b=c?
Actions-
a1: impossible
a2: equilateral triangle
a3: isosceles triangle
a4: scalene triangle
a5: not a triangle
Test Cases:
TEST RESULTS:
Various conditions are taken into account and respective actions based on them are identified
thus generating the test results for the problem statement.
EXPERIMENT-4
AIM: Design Independent paths by calculating cyclomatic complexity using date
SOFTWARE REQUIRED: Turbo C++ Environment.
Problem Statement: Consider a program for the determination of previous date. Its input is a
triple of day, month and year with the values in the range
1 ≤ month ≤ 12
1 ≤ day ≤ 31
1900 ≤ year ≤ 2025
The possible outputs are “Previous date” and “Invalid date”.
Program:
1. #include<iostream.h>
2. # include<conio.h>
3. int leap(int year);
4. void main()
5. {
6. clrscr();
7. intdc,month,date,year,dm,dn,leap;
8. cout<<“Enter the date”;
9. cin>>date;
10. cout<<“\nEnter the month”;
11. cin>>month;
12. cout<<“\nEnter the year:”;
13. cin>>year;
14. cout<<“\nEntered date is:”<<date<<“/”<<month<<“/”<<year;
15. if(leap==0)
16. {
17. if(month==1)
18. dm=0;
19. if(month==2)
20. dm=31;
21. if(month==3)
22. dm=59;
23. if(month==4)
24. dm=90;
25. if(month==5)
26. dm=120;
27. if(month==6)
28. dm=151;
29. if(month==7)
30. dm=181;
31. if(month==8)
32. dm=212;
33. if(month==9)
34. dm=243;
35. if(month==10)
36. dm=273;
37. if(month==11)
38. dm=304;
39. if(month==12)
40. dm=334;
41. }
42. else
43. {
44. if(month==1)
45. dm=0;
46. if(month==2)
47. dm=31;
48. if(month==3)
49. dm=60;
50. if(month==4)
51. dm=91;
52. if(month==5)
53. dm=121;
54. if(month==6)
55. dm=152;
56. if(month==7)
57. dm=182;
58. if(month==8)
59. dm=213;
60. if(month==9)
61. dm=244;
62. if(month==10)
63. dm=274;
64. if(month==11)
65. dm=305;
66. if(month==12)
67. dm=335;
68. }
69. dc=dm+date;
70. cout<<“The no of Day is:”<<dc;
71. dn=dc%7;
72. if(dn==0)
73. cout<<“\nSaturday”;
74. else if(dn==1)
75. cout<<“\nSunday”;
76. else if(dn==2)
77. cout<<“\nMonday”;
78. else if(dn==3)
79. cout<<“\nTuesday”;
80. else if(dn==4)
81. cout<<“\nWednesday”;
82. else if(dn==5)
83. cout<<“\nThursday”;
84. else if(dn==6)
85. cout<<“\nFriday”;
86. getch();
87. }
88. int leap(int year)
89. {
90. if(((year%100==0) && (year%400==0)) || (year%4==0))
91. {
92. return 1;
93. }
94. else
95. return 0;
96. }
Test Cases:
TEST RESULTS:
Number of nodes(n) = 49
EXPERIMENT-5
AIM: Design Independent paths by calculating cyclomatic complexity using Triangle Problem.
SOFTWARE REQUIRED: Turbo C++ Environment.
THEORY: Cyclomatic complexity is software metric (measurement), used to indicate the
complexity of a program. It is a quantitative measure of the number of linearly independent paths
through a program's source code. It gives the maximum number of independent paths in a
program. Two alternate methods are available for the complexity calculations:
Problem Statement: Consider a program for the determination of Previous date. Its input is a
triple of day, month and year with the values in the range
1 ≤ month ≤ 12
1 ≤ day ≤ 31
2000 ≤ year ≤ 2050
The possible outputs are “Previous date” and “Invalid date”. Design the test cases using decision
table-based testing.
Program:
1. #include<iostream.h>
2. # include<conio.h>
3. int leap(int year);
4. void main()
5. {
6. clrscr();
7. int dc,month,date,year,dm,dn,leap;
8. cout<<“Enter the date”;
9. cin>>date;
10. cout<<“\nEnter the month”;
11. cin>>month;
12. cout<<“\nEnter the year:”;
13. cin>>year;
14. cout<<“\nEntered date is:”<<date<<“/”<<month<<“/”<<year;
15. if(leap==0)
16. {
17. if(month==1)
18. dm=0;
19. if(month==2)
20. dm=31;
21. if(month==3)
22. dm=59;
23. if(month==4)
24. dm=90;
25. if(month==5)
26. dm=120;
27. if(month==6)
28. dm=151;
29. if(month==7)
30. dm=181;
31. if(month==8)
32. dm=212;
33. if(month==9)
34. dm=243;
35. if(month==10)
36. dm=273;
37. if(month==11)
38. dm=304;
39. if(month==12)
40. dm=334;
41. }
42. else
43. {
44. if(month==1)
45. dm=0;
46. if(month==2)
47. dm=31;
48. if(month==3)
49. dm=60;
50. if(month==4)
51. dm=91;
52. if(month==5)
53. dm=121;
54. if(month==6)
55. dm=152;
56. if(month==7)
57. dm=182;
58. if(month==8)
59. dm=213;
60. if(month==9)
61. dm=244;
62. if(month==10)
63. dm=274;
64. if(month==11)
65. dm=305;
66. if(month==12)
67. dm=335;
68. }
69. dc=dm+date;
70. cout<<“The no of Day is:”<<dc;
71. dn=dc%7;
72. if(dn==0)
73. cout<<“\nSaturday”;
74. else if(dn==1)
75. cout<<“\nSunday”;
76. else if(dn==2)
77. cout<<“\nMonday”;
78. else if(dn==3)
79. cout<<“\nTuesday”;
80. else if(dn==4)
81. cout<<“\nWednesday”;
82. else if(dn==5)
83. cout<<“\nThursday”;
84. else if(dn==6)
85. cout<<“\nFriday”;
86. getch();
87. }
88. int leap(int year)
89. {
90. if(((year%100==0) && (year%400==0)) || (year%4==0))
91. {
92. return 1;
93. }
94. else
95. return 0;
96. }
TEST RESULTS:
EXPERIMENT-6
Problem Statement: Give the present date in the form of a triplet of day, month and year. To
check whether the date given is valid or invalid. If valid then the output is previous date.
Program:
1. #include<stdio.h>
2. #include<conio.h>
3. void main()
4. {
5. clrscr();
6. int day,month,year,flag=0;
7. int prev_day, prev_month, prev_year;
8. Printf(“enter the date=dd-mm-yy”);
9. Printf(“\nenter the day:”);
10. Scanf(“%d”,&day);
11. Printf(“\nenter the month:”);
12. Scanf(“%d”,&month);
13. Printf(“\nenter the year:”);
14. Scanf(“%d”,&year);
15. if((day>=1 && day<=31) && (month==1 || month==3|| month==5||
16. month==7|| month==8|| month==10 month==12||) && (year>=1))
17. {
18. Printf(“The date entered is valid”);
19. flag=1;
20. }
21. else if((day>=1 && day<=30) && (month==4|| month==6|| month==9||
22. month==11) && (year>=1))
23. {
24. Printf(“The date entered is valid”);
25. flag=1;
26. }
27. else if((day>=1 && day<=29) && (month=2) && (year>=1) && ((year%100==0
&& year%400==0) || (year>=1) && (year%100!==0 && year%4==0)))
28. {
29. Printf(“The date entered is valid”);
30. flag=1;
31. }
32. else if((day>=1 && day<=28) && (month==2) && (year>=1))
33. {
34. Printf(“The date entered is valid”);
35. flag=1;
36. }
37. else
38. {
39. Printf(“\n The date is invalid”);
40. }
41. if(flag==1)
42. {
43. if(day>=2)
44. {
45. prev_day = -prev_day;
46. printf(“\nThe previous date is:%d%d%d”,&prev_day,&month,&year);
47. }
48. else if(day==1)
49. {
50. if(month==1)
51. {
52. prev_day = 31;
53. prev_month = 12;
54. prev_year= -year;
55. printf(“\nThe previous date is:%d%d%d”,&prev_day,&month,&year);
56. }
57. if(month==5||month==7|| month==10||month==12)
58. {
59. prev_day = 31;
60. prev_month = -month;
61. printf(“\nThe previous date is:%d%d%d”,&prev_day,&month,&year);
62. }
63. else if(month==2|| month==4|| month==6||month==8|| month==9|| month==11)
64. {
65. prev_day = 31;
66. prev_month = -month;
67. printf(“\nThe previous date is:%d%d%d”,&prev_day,&month,&year);
68. else
69. if(month==3)
70. {
71. if((year%100==0 && year%400==0) || (year>=1) && (year%100!==0
&& year%4==0))
72. {
73. prev_day = 29;
74. prev_month = -month;
75. printf(“\nThe previous date is:%d%d%d”,&prev_day,&month,&year);
76. }
77. else
78. {
79. prev_day = 28;
80. prev_month = -month;
81. printf(“\nThe previous date is:%d%d%d”,&prev_day,&month,&year);
82. }
83. }
84. }
85. }
86. getch();
87. }
FLOW GRAPH: