This document describes four experiments in software testing. The first experiment involves generating random test data for a triangle classification program. The second experiment applies black box testing techniques like boundary value analysis, equivalence partitioning, and decision tables to test a date calculation program. The third experiment title is listed but no details are provided. Overall, the document outlines methods to test programs using random and structured test data generation and analyzes the results.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
237 views
Mangesh Software Testing Lab Manual
This document describes four experiments in software testing. The first experiment involves generating random test data for a triangle classification program. The second experiment applies black box testing techniques like boundary value analysis, equivalence partitioning, and decision tables to test a date calculation program. The third experiment title is listed but no details are provided. Overall, the document outlines methods to test programs using random and structured test data generation and analyzes the results.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 1
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.
Veermata Jijabai Technological Institute, Mumbai 2
fclose(f); }
2. STLab1TriangleCheck.c #include<stdio.h> //check type of triangle with respect to given inputs void TriangleCheck(int ax, int bx, int cx) { if(ax==bx==cx) { printf("\nIts Equilateral\n"); } else if(cx>(ax+bx)||bx>(ax+cx)||ax>(bx+cx)) { printf("\n Its not a Triangle\n"); } else if(ax==bx || bx==cx || ax==cx) { printf("\n Its Isoceles\n"); } else { printf("\n Its Scalene\n"); } }
3.STLabTesting.c #include "STLab1TriangleCheck.c" #include<stdio.h> #include<conio.h> #include<stdlib.h> //main function int main() { FILE *fp; fp=fopen("TestFile.txt","r"); int a,b,c; while(!feof(fp)) { fscanf(fp,"%d",&a); Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 3
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++.
*****
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 6
Experiment No.02
TITLE: Black Box Testing Techniques: 1. Boundary Value Analysis 2. Equivalence Class Partition 3. Decision Table
PROBLEM: NextDate : It is a function of three variables: day, month, year This 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 <= 12 C2: 1 <= Day <= 31 C3: 1812 <= Year <= 2020 Write a program in C, C++, Java programming language.
Generate Test Cases using : 1) Boundary value Analysis 2) Equivalence Class Partition 3) 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 days bool 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; } } Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 7
Veermata Jijabai Technological Institute, Mumbai 9
int main() { int day,month,year; cout<<"Enter date as an input: [dd mm yyyy]"<<endl; cin>>day>>month>>year; bool validity=isDateValid(day,month,year); if(validity == true) { getNextDate(day,month,year); } return 0; }
OBSERVATION: (i) Boundary Value Analysis: As there are three inputs in this particular program, We will be using 4n+1 = 4*3+1= 13 Test cases . Type Day Month Year Expected Output Normal BVA 1 2 1990 2-2-1990 2 3 1900 3-3-1900 30 4 2004 1-5-2004 31 5 2010 1-6-2010 7 1 1890 8-1-1890 15 2 2012 16-2-2012 20 11 2004 21-11-2004 5 12 2014 6-12-2014 5 3 1812 6-3-1812 7 5 1813 8-5-1813 15 7 2019 16-7-2019 17 11 2020 18-11-2020 Normal 7 5 1994 8-5-1994 Robust BVA 0 5 1993 Invalid Input!! 32 7 1994 Invalid Input!! 7 0 2000 Invalid Input!! 5 13 2004 Invalid Input!! 4 5 1811 Invalid Input!! 6 10 2021 Invalid Input!!
Valid Output % : 68.4% Invalid Output %: 31.6%
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 10
(ii) Equivalence Class Partition:[ Valid Output: 33.33% Invalid Output: 66.66%] Variable Type Day Month Year Output Day < Min -1 5 1994 Invalid Normal 7 5 2004 Valid > Max 32 5 2014 Invalid Month <Min 7 -1 1900 Invalid Normal 25 10 1993 Valid > Max 5 13 2001 Invalid Year <Min 25 5 1811 Invalid Normal 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 <= 31 C2 : 1 <= Month <=12 C3 : 1812 <= Year <= 2020 C4 : Leap Year OR Not leap year Test No. C1 C2 C3 C4 Valid Invalid 1 N N N N N Y 2 N N N Y N Y 3 N N Y N N Y 4 N N Y Y N Y 5 N Y N N N Y 6 N Y N Y N Y 7 N Y Y N N Y 8 N Y Y Y N Y 9 Y N N N N Y 10 Y N N Y N Y 11 Y N Y N N Y 12 Y N Y Y N Y 13 Y Y N N N Y 14 Y Y N Y N Y 15 Y Y Y N Y N 16 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.
***** Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 11
Experiment No.03
TITLE: Random test data generation.
Software Testing Lab Manual[2014]
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]
Veermata Jijabai Technological Institute, Mumbai 16
Experiment No.04
TITLE: Write a Program In Java To Demonstrate The Working Of Following Statement Controls And Construct Test Cases: 1. dowhile 2. while 3. ifelse 4. 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 TestDoWhile { public static void main(String args[]) { try { Scanner s=new Scanner(System.in); int temp=0; temp=s.nextInt(); do { System.out.println("Value of TEMP is->"+temp); temp--; } while(temp!=0); } catch(Exception e) { System.out.println("Error !!!"); } } Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 17
} TEST CASES: Test Case ID temp Expected Output Output Result 1 5 Successful Successful Pass 2 -5 Infinite Loop Successful Fail 3 -5 Infinite Loop Infinite Loop Pass 4 A Invalid Input Invalid Input Pass
2. While //TestWhile.java import java.util.Scanner;
class TestWhile { public static void main(String args[]) { try { Scanner s=new Scanner(System.in); int temp=0; temp=s.nextInt(); while(temp!=0) { System.out.println("Value of TEMP is->"+temp); temp--; } } catch(Exception e) { System.out.println("Error !!!"); } } }
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 18
TEST CASES: Test Case ID temp Expected Output Output Result 1 5 Successful Successful Pass 2 -5 Infinite Loop Successful Fail 3 -5 Infinite Loop Infinite Loop Pass 4 A Invalid Input Invalid Input Pass
3. If Else //TestIfElse.java import java.util.Scanner;
class TestIfElse { public static void main(String args[]) { try { Scanner s=new Scanner(System.in); int a=s.nextInt(); if(a==101) { System.out.println("A is lucky number"); } else { System.out.println("A is not lucky number"); } } catch(Exception e) { e.printStackTrace(); } } }
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 19
TEST CASES: Test Case ID a Expected Output Output Result 1 101 Successful Successful Pass 2 25 Successful Successful Pass 3 abc Invalid Input Successful Fail 4 abc Invalid Input Invalid Input Pass 5 -43 Successful Successful Pass
4. Switch case //TestSwitch.java import java.util.Scanner;
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(); } } Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 20
}
TEST CASES: Test Case ID a Expected Output Output Result 1 1 Successful Successful Pass 2 2 Successful Successful Pass 3 3 Successful Successful Pass 4 4 Successful Successful Pass 5 5 Successful Successful Pass 6 5 Successful Error Fail 7 x Invalid Input Invalid Input Pass 8 x Invalid Input Successful Fail
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.
*****
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 21
Experiment No.05
TITLE: 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++) { Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 22
TEST CASES: Test Case ID R1 R2 C1 C2 Element Type Expected Output Output Remark 1 2 3 3 1 Int Success Success Pass 2 2 1 2 3 Int Multiplication not possible Multiplication not possible Pass 3 3 3 3 3 +ve Int Success Success Pass 4 3 2 2 3 -ve Int Success Success Pass 5 2 3 3 2 +ve/-ve Float Garbage Garbage Pass 6 1 2 2 1 Char Multiplication not possible Success Fail
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 23
CONCLUSION: In this experiment, I have examined failure causes by considering variations in rows,columns and contents of the matrix.
*****
Software Testing Lab Manual[2014]
Veermata Jijabai Technological Institute, Mumbai 24
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.
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,c int 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; }
TEST CASES: Test Case ID a b c Expected Output Output Remark 1 2 3 4 5.3851 5.3851 Pass 2 2.2 3.3 4.4 Int Values Expected Int Values Expected Pass 3 -2 -3 -4 5.3851 5.3851 Pass
CONCLUSION: In this experiment, I have examined different failure causes by considering various data types and qualifiers for variables a,b and c.