Lab 2 Software Testing 22/09/2021
Errors, Fault, Failures:
Statement Purpose:
The purpose of this lab is to create an understanding of the fundamental concepts of Software
Testing like Errors, Fault/Bug/Defect, Failure.
Activity Outcomes:
- Understanding of Error, Fault and Failure in Java Program.
- Student will be able to find Bugs in any of the software products.
1) Stage J (Journey)
Introduction:
According to IEEE Definitions:
Fault : It is a condition that causes the software to fail to perform its required function.
Error : Refers to difference between Actual Output and Expected output.
Failure : It is the inability of a system or component to perform required function according
to its specification.
Failure: External behavior is incorrect
Fault: Discrepancy in code that causes a failure.
Error: Human mistake that caused fault
Note:
Error is terminology of Developer.
Bug is terminology of Tester
2) Stage a1 (apply)
Lab Activity 1:
The example demonstrates the difference in Error, Fault and Failure.
pre: param is an integer.
post: returns the product of the param multiplied by 2.
1. int double (int param) {
2. int result;
3. result = param * param;
4. return result;
5. }
Identification of Error, Fault and Failures
. A call to double(3) returns 9, but the post condition says it should return 6.
• Result 9 represents a failure.
• The failure is due to the fault at line 3, ( "* param" is used instead of "* 2")
• The error is a typo, ( someone typed "* param" instead of "* 2" by mistake).
Lab Activity 2:
The example demonstrates the difference in Error, Fault and Failure.
2) Stage v (verify)
Activity 1:
Evaluate software by observing it’s execution. Introduce some errors, faults and failures to explain
your answer.
Consider the concept of a CourseResult. The CourseResult should have data members like
the student name, course name and grade obtained in that course. This concept can be
represented in a class as follows:
Public class CourseResult
{
Public String studentname;
Public String coursename;
Public String grade;
public void display()
{
System.out.println("Student Name is: ― + studentname + "Course Name is: ― +
coursename + "Grade is: ― + grade); }
}
Public class CourseResultRun
{
public static void main(String[]args)
{
CourseResult c1=new CourseResult (); c1.studentName= ―Ali‖; c1.courseName= ―OOP‖;
c1.grade= ―A‖;
c1.display();
CourseResult c2=new CourseResult ();
c2.studentName= ―Saba‖;
c2.courseName= ―ICP‖;
c2.grade= ―A+‖;
c2.display();
}
}
Activity 2:
Design a class Point with two data members x-cord and y-cord. This class should have an arguments
constructor, setters, getters and a display function. Now create another class ―Line‖, which contains
two Points ―startPoint‖ and ―endPoint‖. It should have a function that finds the length of the line.
Hint: formula is: sqrt((x2-x1) 2 + (y2-y1) 2 ) Create two line objects in runner and display the length
of each line.
Write test cases to check the above functionality by introducing different errors, faults and failure
Mention 3 test cases for failures and 3 for Non failures as shown in above example.
Activity 3:
Find the maximum number of bugs in the following website and fill the provided Bug report sheet
template.
https://homeshopping.pk/