Software Testing Lab Manual[2014] Experiment No.01 TITLE: Random test data generation. PROBLEM: Consider the triangle program that accepts three integers a,b and c, as input. These are taken sides of a triangle. The output of the program is the type of the triangle determined by the three sides: Equilateral, Isosceles, scalene, or not a triangle. Constraints on input are as follows: C1: 1<=a<=200; C2: 1<=b<=200; C3: 1<=c<=200; C4: a<b+c; C5: b<a+c; C6: c<b+a; Write a program in C,C++, Java Programming Language. Generate test cases using random test data generator. Test program using the input generated by Random method. Write percentage for each type of the output generated by given test data. Write your observation for test cases and percentage test cases generated for each type of output. PROGRAMS: 1. STLab1.c #include<stdio.h> #include<conio.h> #include<stdlib.h> //to generate random numbers int generateRandomNumber() { return rand() % 201; } //main function void main() { Veermata Jijabai Technological Institute, Mumbai 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Software Testing Lab Manual[2014]
Experiment No.01
TITLE: Random test data generation.
PROBLEM:Consider the triangle program that accepts three integers a,b and c, as input. These are taken sides of a triangle. The output of the program is the type of the triangle determined by the three sides: Equilateral, Isosceles, scalene, or not a triangle. Constraints on input are as follows:C1: 1<=a<=200; C2: 1<=b<=200; C3: 1<=c<=200;C4: a<b+c; C5: b<a+c; C6: c<b+a;Write a program in C,C++, Java Programming Language.Generate test cases using random test data generator. Test program using the input generated by Random method. Write percentage for each type of the output generated by given test data.Write your observation for test cases and percentage test cases generated for each type of output.
PROGRAMS:1. STLab1.c#include<stdio.h>#include<conio.h>#include<stdlib.h>//to generate random numbersint generateRandomNumber(){
Veermata Jijabai Technological Institute, Mumbai 2
Software Testing Lab Manual[2014]
fscanf(fp,"%d",&c);TriangleCheck(a,b,c);
}fclose(fp);return 0;
}
4. TestFile.txt [ScreenShot]
OBSERVATION:
Veermata Jijabai Technological Institute, Mumbai 3
Software Testing Lab Manual[2014]
Table 1:Test Case ID A B C Expected
Output1. 41 176 103 Not a triangle2. 169 74 46 Not a triangle3. 21 12 28 Scalene4. 143 77 5 Not a triangle5. 166 144 112 Scalene6. 89 181 83 Not a triangle7. 3 9 30 Not a triangle8. 132 83 153 Scalene9. 91 121 135 Scalene10. 23 20 197 Not a triangle11. 20 18 98 Not a triangle12. 81 60 13 Not a triangle13. 140 169 151 Scalene14. 45 161 93 Not a triangle15. 167 183 186 Scalene16. 41 66 73 Scalene17. 113 34 20 Not a triangle18. 107 100 195 Scalene19. 138 196 80 Scalene20. 93 193 175 Scalene21. 55 20 80 Not a triangle22. 33 87 157 Not a triangle23. 196 98 169 Scalene24. 136 110 87 Scalene25. 11 96 49 Not a triangle
Table 2:
Veermata Jijabai Technological Institute, Mumbai 4
Software Testing Lab Manual[2014]
Test Case ID Not a Triangle Isosceles Scalene Equilateral
Veermata Jijabai Technological Institute, Mumbai 5
CONCLUSION:In this practical, I have written simple codes to generate random numbers to be taken as input by another program as test case data. By observing outputs for each test data, I have filled up two tables showing output for each test case and its percentage for each type of triangle. It was my really interesting to test simple code using C++.
*****
Experiment No.02
Veermata Jijabai Technological Institute, Mumbai 6
Software Testing Lab Manual[2014]
TITLE: Black Box Testing Techniques:
1. Boundary Value Analysis2. Equivalence Class Partition3. Decision Table
PROBLEM:NextDate :
It is a function of three variables: day, month, yearThis function takes input date and it returns the next date. The constraints on day, month and year integer variables are as follows:
C1 : 1 <= Month <= 12C2: 1 <= Day <= 31C3: 1812 <= Year <= 2020
Write a program in C, C++, Java programming language.
Generate Test Cases using :1) Boundary value Analysis2) Equivalence Class Partition3) Decision Table
Test program using the test cases generated by above techniques.Write percentage for each type of the output generated by the given test cases.
PROGRAM:1. date.cpp #include<iostream>using namespace std;//to check if month having 30 daysbool isMonthOfThirty(int MonthNum){
int i,MonthOfThirty[]={4,6,9,11};for(i=0;i<(sizeof(MonthOfThirty)/sizeof(int));i++){
if(MonthOfThirty[i]==MonthNum){
return true;}
}}
Veermata Jijabai Technological Institute, Mumbai 7
Software Testing Lab Manual[2014]
//to check if date is validbool isDateValid(int dd,int mm,int yyyy){
Year <Min 25 5 1811 InvalidNormal 7 10 1994 Valid> Max 5 1 2021 Invalid
(iii) Decision Table:[ Valid Output: 12.5% Invalid Output: 87.5%]Constraints are:C1 : 1 <= Day <= 31C2 : 1 <= Month <=12C3 : 1812 <= Year <= 2020C4 : Leap Year OR Not leap year
Test No. C1 C2 C3 C4 Valid Invalid1 N N N N N Y2 N N N Y N Y3 N N Y N N Y4 N N Y Y N Y5 N Y N N N Y6 N Y N Y N Y7 N Y Y N N Y8 N Y Y Y N Y9 Y N N N N Y10 Y N N Y N Y11 Y N Y N N Y12 Y N Y Y N Y13 Y Y N N N Y14 Y Y N Y N Y15 Y Y Y N Y N16 Y Y Y Y Y N
CONCLUSION:In this experiment, I have studied about the concept of Black Box Testing. And I have used few techniques such as Boundary Value Analysis, Equivalence Class Partition & Decision Table to test simple code in which I am trying to find next date. I have used C language to implement this particular solution.
*****
Experiment No.03
TITLE:
Veermata Jijabai Technological Institute, Mumbai 11
Software Testing Lab Manual[2014]
Random test data generation.
Veermata Jijabai Technological Institute, Mumbai 12
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 13
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 14
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 15
Software Testing Lab Manual[2014]
Experiment No.04
TITLE:
Veermata Jijabai Technological Institute, Mumbai 16
Software Testing Lab Manual[2014]
Write a Program In Java To Demonstrate The Working Of Following Statement Controls And Construct Test Cases:1. do…while2. while3. if…else4. switch case
THEORY:In this practical we are going to provide inputs of different types and going to check the expected and observed results . We are going to apply different inputs for control and looping statements to generate test cases.
class TestSwitch{ public static void main(String args[]) { try { System.out.println("Enter proper choice: \n 1. Add \n 2. Subtract \n 3. Show \n 4. Exit \n"); Scanner s=new Scanner(System.in); int a=s.nextInt(); switch(a) { case 1: System.out.println("Your choice is to Add"); break; case 2: System.out.println("Your choice is to subtract"); break; case 3: System.out.println("Your choice is to show"); break; case 4: System.out.println("Your choice is to exit"); break; default:System.out.println("Enter proper valid choice!!"); } } catch(Exception e) { e.printStackTrace(); } }}
TEST CASES:Test Case ID a Expected Output Result
Veermata Jijabai Technological Institute, Mumbai 20
CONCLUSION:In this experiment, I have tried to test simple control statements and looping statements. I have implemented few programs in Java and tested it by applying different types of inputs to generate test cases.
*****
Experiment No.05
TITLE:
Veermata Jijabai Technological Institute, Mumbai 21
Software Testing Lab Manual[2014]
Program for matrix multiplication . Introspect the causes for its failures and write down the possible reasons for its failures.
THEORY:The program multiplies two matrices and checks for the valid and invalid output with causes of failure being the order of the matrix and entries of the matrix.
PROGRAM:#include<stdio.h>
int main(){
int row1,col1,row2,col2;int a[10][10];int b[10][10];int c[10][10];printf("Enter number of rows and colums of both matrix\n");scanf("%d %d %d %d",&row1,&col1,&row2,&col2);if(row1>0 && row2>0 && col1>0 && col2>0 && col1==row2 && row1<10 &&
row2<10 && col1<10 && col2<10){
int i=0,j=0;printf("Enter first matrix values:\n");for(i=0;i<row1;i++){
for(j=0;j<col1;j++)scanf("%d",&a[i][j]);
}
printf("Enter second matrix values:\n");for(i=0;i<row2;i++){
for(j=0;j<col2;j++)scanf("%d",&b[i][j]);
}
int k=0;for(i=0;i<row1;i++){
for(j=0;j<col2;j++){
int sum=0;for(k=0;k<col1;k++){
Veermata Jijabai Technological Institute, Mumbai 22
Software Testing Lab Manual[2014]
sum+=a[i][k]+b[k][j];}c[i][j]=sum;
}}int i1=0,j1=0;for(i1=0;i1<row1;i1++){
printf("\n");for(j1=0;j1<col2;j1++)
printf("%d ",c[i1][j1]);}printf("\n");
}else{
printf("Invalid Input\n");}return 1;
}
TEST CASES:Test Case ID
R1 R2 C1 C2 Element Type
Expected Output
Output Remark
1 2 3 3 1 Int Success Success Pass2 2 1 2 3 Int Multiplication
CONCLUSION:In this experiment, I have examined failure causes by considering variations in rows,columns and contents of the matrix.
Veermata Jijabai Technological Institute, Mumbai 23
Software Testing Lab Manual[2014]
*****
Experiment No.06
TITLE: Program to calculate the root mean square value with reference to three integers a, b, c. Introspect the causes for its failures and write down the possible reasons for its failures.
Veermata Jijabai Technological Institute, Mumbai 24
Software Testing Lab Manual[2014]
THEORY:The program calculates the RMS value for the valid and invalid output with causes of failure being the data types of a, b & c.
PROGRAM:#include<stdio.h>#include<math.h>#include<stdlib.h>//to find RMS value of a,b,cint main(){
int a,b,c;int rms;printf("Enter the values for A, B and C:");scanf("%d%d%d",&a,&b,&c);rms=(a*a)+(b*b)+(c*c);printf("RMS -> %f \n",sqrt(rms)); return 0;