Chapter 1 SFT
Chapter 1 SFT
22518
Chapter 1
Basics of software testing and Testing Methods
(R-04, U-04, A-06 =14 Marks)
1.1 Software Testing, Objective of Testing.
1.2 Failure, Fault, Error, Defect, Bug terminology
1.3 Test Case, When to Start and Stop Testing
1.4 Quality Assurance, Quality Control and Verification - Validation
1.5 Static and dynamic testing.
1.6 The box approaches: White Box Testing: Inspections, Walkthroughs, Technical
Review, Code Functional Testing, Code Coverage Testing, Code Complexity Testing.
1.7 Black Box Testing: Requirement Based Testing, Boundary Value Analysis, Equivalence
Partitioning.
1
Software Testing (22518) CO5I
Testing is the process of identifying defects, where a defect is any variance between actual and
expected results.
“A mistake in coding is called Error, error found by tester is called Defect, defect accepted by
development team then it is called Bug, build does not meet the requirements then it Is Failure.”
Wrong: When requirements are implemented not in the right way. This defect is a variance from
the given specification. It is Wrong!
Missing: A requirement of the customer that was not fulfilled. This is a variance from the
specifications, an indication that a specification was not implemented, or a requirement of the
customer was not noted correctly.
Extra: A requirement incorporated into the product that was not given by the end customer. This
is always a variance from the specification, but may be an attribute desired by the user of the
product. However, it is considered a defect because it’s a variance from the existing requirements.
BUG: A bug is the result of a coding error. An Error found in the development environment before
the product is shipped to the customer. A programming error that causes a program to work poorly,
produce incorrect results or crash. An error in software or hardware that causes a program to
malfunction. Bug is terminology of Tester.
FAILURE: A failure is the inability of a software system or component to perform its required
functions within specified performance requirements. When a defect reaches the end customer it
is called a Failure. During development Failures are usually observed by testers.
FAULT: An incorrect step, process or data definition in a computer program which causes the
program to perform in an unintended or unanticipated manner. A fault is introduced into the
software as the result of an error. It is an anomaly in the software that may cause it to behave
incorrectly, and not according to its specification. It is the result of the error.
The program to find the factorial of a number given below lists a few errors, problems and failures
in a program.
2
Software Testing (22518) CO5I
For example
1. #include<stdio.h>
2. void main()
3. {
4. int i , fact, n;
5. printf(“enter the number “);
6. scanf(“%d”,&n);
7. for(i =1 ;i <=n;i++)
8. fact = fact * i;
9. printf (“the factorial of a number is ”%d”, fact);
10. }
As in line number 4 the fact is not initialized to 1, so it takes garbage value and gives a wrong
output, this is an example of a bug.
If fact is initialized to zero (fact = 0) then the output will be zero as anything multiplied by zero
will give the output as zero. This is a bug which can be removed by initializing fact = 1 during
initializing.
As the fact is declared as integer, for the number till 7! will work perfectly. When the number
entered is 8, the output is garbage value as the integer limit is from – 32767 to +32768, so in
declaration change the initialization to long int fact
test, how long it will take, and if the problem they’re looking at is really a bug. The job of a
software tester is in time constraints. They have to find the bugs as early as possible.
7. They are tactful and diplomatic: - Software testers are always the bearers of bad news. They
have to tell the programmers about the various bugs and the error that exist in their program
and it has to be told carefully. Good software testers know how to do so tactfully and
professionally and know how to work with programmers who aren’t always tactful and
diplomatic.
8. They are persuasive: - Bugs that testers find won’t always be viewed as severe enough to be
fixed. Testers need to be good at making their points clear, demonstrating why the bug does
indeed need to be fixed, and following through on making it happen.
4
Software Testing (22518) CO5I
Verification
1. It makes sure that the product is designed to deliver all functionality to the customer.
2. Verification is done at the starting of the development process. It includes reviews and
meetings, walkthroughs, inspection, etc. to evaluate documents, plans, code, requirements
and specifications.
3. It answers the questions like: Am I building the product, right?
4. Am I accessing the data right (in the right place; in the right way).
5. It is a Low-level activity
6. Performed during development on key art facts, like walkthroughs, reviews and
inspections, mentor feedback, training, checklists and standards.
7. Demonstration of consistency, completeness, and correctness of the software at each stage
and between each stage of the development life cycle.
Validation
1. Determining if the system complies with the requirements and performs functions for
which it is intended and meets the organization’s goals and user needs.
2. Validation is done at the end of the development process and takes place after verifications
are completed.
3. It answers the question like: Am I building the right product?
4. Am I accessing the right data (in terms of the data required to satisfy the requirement)?
5. It is a High-level activity.
6. Performed after a work product is produced against established criteria ensuring that the
product integrates correctly into the environment.
7. Determination of correctness of the final software product by a development project with
respect to the user needs and requirements.
5
Software Testing (22518) CO5I
2 It does not involve executing the code It always involves executing the code
Verification uses methods like reviews, It uses methods like Black Box
3 walkthroughs, inspections, and desk- Testing, White Box Testing, and non-
checking etc. functional testing
It finds bugs early in the development It can find bugs that the verification
5
cycle process cannot catch
QA team does verification and makes sure With the involvement of testing team
7 that the software is as per the requirement validation is executed on software
in the SRS document. code.
6
Software Testing (22518) CO5I
Quality Control
1. A part of quality management focused on fulfilling quality requirements.
2. The operational techniques and activities used to fulfill requirements for quality.
3. Quality Control on the other hand is the physical verification that the product conforms to
these planned arrangements by inspection, measurement etc.
4. Quality Control is the process involved within the system to ensure job management,
competence and performance during the manufacturing of the product or service to ensure
it meets the quality plan as designed.
5. Quality Control just measures and determines the quality level of products or services. It is
a process itself.
7
Software Testing (22518) CO5I
Dynamic testing
1. Dynamic testing is testing that is performed when the system is running.
2. This testing is also called an Execution technique or validation testing.
3. It checks for functional behavior of the software system, memory/CPU usage and overall
performance of the system.
4. The main objective of this testing is to confirm that the software product works in conformance
with the business requirements.
5. Dynamic testing executes the software and validates the output with the expected outcome.
6. Dynamic testing is performed at all levels of testing and it can be either black or white box
testing.
2 This testing does the verification process Dynamic testing does the validation process
Static testing gives an assessment of code Dynamic testing gives bugs/bottlenecks in the
4
and documentation software system.
Static testing covers the structural and Dynamic testing techniques are Boundary Value
7
statement coverage testing Analysis & Equivalence Partitioning.
8 Cost of finding defects and fixing is less Cost of finding and fixing defects is high
Return on investment will be high as this Return on investment will be low as this process
9
process involved at an early stage involves after the development phase
More reviews comments are highly More defects are highly recommended for good
10
recommended for good quality quality.
Static testing covers the structural and Dynamic testing techniques are Boundary Value
12
statement coverage testing Analysis & Equivalence Partitioning.
8
Software Testing (22518) CO5I
1.6 The box approach: White Box Testing: Inspections, Walkthroughs, Technical
Review, Code Functional Testing, Code Coverage Testing, Code Complexity Testing.
Advantages
1. As the tester has knowledge of the source code
2 . It becomes very easy to find out which type of data can help in testing the application effectively.
3. Extra lines of code can be removed which can bring in hidden defects.
4. It helps in optimizing the code.
5. Due to the tester's knowledge about the code, maximum coverage is attained during writing test
cases.
Disadvantages
1.Due to the fact that a skilled tester is needed to perform
2. Necessity to create a full range of inputs to test each path and condition make the white box
testing method time-consuming.
3. Some conditions might be untested as it is not realistic to test every single one.
4. Specialized tools like code analysers and debugging tools are required.
9
Software Testing (22518) CO5I
The tester is unaware of the system architecture and does not have access to the source code.
Testers interact with the system's user interface by providing inputs. Examining outputs without
knowing how and where the inputs are worked upon.
Advantages
1. Well suited and efficient for large code segments.
2. Code Access not required.
3. Test is performed from a user’s point-of-view and not of the designer’s.
4. Tester is free from any pressure of knowledge of specific programming languages to test the
functionality of an application.
5. Test cases can be designed as soon as the specifications are complete.
Disadvantages
1. Blind Coverage, since the tester cannot target specific code segments or error prone areas.
2. Testing every possible input stream is not possible because it is time-consuming.
3. Inefficient testing, due to the fact that the tester only has limited knowledge about an application.
4. The test cases are difficult to design.
Inspections
1. Inspections are the most formal type of reviews.
2. They are highly structured and require training for each participant.
3. Inspections are different from peer reviews and walkthroughs in that the person who presents
the code, the presenter or reader, isn’t the original programmer.
4. This forces someone else to learn and understand the material being presented, potentially giving
a different slant and interpretation at the inspection meeting.
5. The other participants are called inspectors.
6. Each is tasked with reviewing the code from a different perspective, such as a user, a tester, or
a product support person.
7. This helps bring different views of the product under review and very often identifies different
bugs.
8. One inspector is even tasked with reviewing the code backward—that is, from the end to the
beginning—to make sure that the material is covered evenly and completely.
Walkthroughs
1. A walk through is an evaluation process which is an informal meeting, which does not require
preparation.
2. Author presents their developed artifact to an audience of peers.
3. Peers question and comment on the artifact to identify as many defects as possible.
4. In a walkthrough, the programmer who wrote the code formally presents (walks through) it to a
small group of five or so other programmers and testers.
3. The reviewers should receive copies of the software in advance of the review so they can
examine it and write comments and questions that they want to ask at the review.
4. Having at least one senior programmer as a reviewer is very important.
Technical Review
1. Formal Review
2. Peer Review
1. Formal Review
1. A formal review is the process under which static white-box testing is performed.
2. A formal review can range from a simple meeting between two programmers to a detailed,
rigorous inspection of the code.
2. Follow Rules: - A fixed set of rules should be followed. They may set the amount of
code to be reviewed (usually a couple hundred lines), how much time will be spent (a couple
hours), what can be commented on, and so on. This is important so that the participants know what
their roles are and what they should expect. It helps the review run more smoothly.
3. Prepare: - Each participant is expected to prepare for and contribute to the review.
Depending on the type of review, participants may have different roles. They need to know what
their duties and responsibilities are and be ready to actively fulfill them at the review. Most of the
problems found through the review process are found during preparation, not at the actual review.
4. Write a Report: - The review group must produce a written report summarizing the results
of the review and make that report available to the rest of the product development team. It’s
imperative that others are told the results of the meeting—how many problems were found, where
they were found, and so on.
2. Peer Reviews
1. The easiest way to get team members together and doing their first formal reviews of the
software is through peer reviews, the least formal method.
2. Sometimes called buddy reviews, this method is really more of a discussion.
3. Peer reviews are often held with just the programmer who wrote the code and one or two other
programmers or testers acting as reviewers.
4. Small group simply reviews the code together and looks for problems and oversights.
5. To assure that the review is highly effective all the participants need to make sure that the four
key elements of a formal review are in place: Look for problems, follow rules, prepare for the
review, and write a report.
6. As peer reviews are informal, these elements are often scaled back. Still, just getting together to
discuss the code can find bugs.
12
Software Testing (22518) CO5I
Structural Testing-
1. Code Functional Testing,
2. Code Coverage Testing,
3. Code Complexity Testing
void main( )
{
int a,b,c;
printf(“Enter values of a and b”);
scanf(“%d%d”,&a,&b);
C=a+b;
C=c/2;
print(“Average=%d”,c);
}
o/p:- Enter values of a and b 2 4
Average=3
Intermediate values a==2 b=4 , C=6, C=3
13
Software Testing (22518) CO5I
b. Data coverage
Coverage is a measure of the completeness of the set of test cases. Consider the data first.
Data includes all the variables, constants, arrays, data structures, keyboard and mouse input, files
and screen input and output, and I/O to other devices such as modems, networks, and so on.
For example
1. #include<stdio.h>
2. void main()
3. {
4. int i , fact= 1, n;
5. printf(“enter the number “);
6. scanf(“%d”,&n);
7. for(i =1 ;i <=n;i++)
8. fact = fact * i;
9. printf (“the factorial of a number is ”%d”,
fact);
10. }
The declaration of data is complete with the assignment statement and the variable declaration
statements. All the variables declared are properly utilized.
14
Software Testing (22518) CO5I
For very small programs or individual modules, using a debugger is often sufficient. However,
performing code coverage on most software requires a specialized tool known as a code coverage
analyzer
` b. Branch Coverage
1. Attempting to cover all the paths in the software is called path testing.
2. The simplest form of path testing is called branch coverage testing.
3. To check all the possibilities of the boundary and the sub boundary conditions and it’s branching
on those values.
4. Test coverage criteria requires enough test cases such that each condition in a decision takes on
all possible outcomes at least once, and each point of entry to a program or subroutine is invoked
at least once.
5. Every branch (decision) taken each way, true and false.
6. It helps in validating all the branches in the code making sure that no branch leads to abnormal
behavior of the application.
If you test this program with the goal of 100% statement coverage, you need to run only a single
test case with the Date$ variable set to January 1, 2000.
The program would then execute the following path: Lines 1, 2, 3, 4, 5, 6, 7
Need to try a test case for a date that’s not January 1,2000.
If you did, the program would execute the other path through the program: Lines 1, 2, 5, 6, 7
15
Software Testing (22518) CO5I
Most code coverage analyzers report both statement coverage and branch coverage results
separately.
c. Condition Coverage
An extra condition is added to the IF statement in line 2 that checks the time as well as the date.
Condition coverage testing takes the extra conditions on the branch statements into account.
If you were concerned only with branch coverage, the first three conditions would be redundant
and could be equivalence partitioned into a single test case.
But, with condition coverage testing, all four cases are important because they exercise different
conditions of the IF statement in line 4.
Mathematically, for a structured program, the directed graph inside control flow is the
edge joining two basic blocks of the program as control may pass from first to second.
So, cyclomatic complexity M would be defined as,
M=E–N+2
where,
E = the number of edges in the control flow graph
N = the number of nodes in the control flow graph
Or
M= P + 1
Where P = Number of predicate nodes (node that contains condition)
Steps that should be followed in calculating cyclomatic complexity and test cases design are:
The cyclomatic complexity calculated for above code will be from the control flow graph. The
graph shows seven shapes(nodes), seven lines(edges), hence cyclomatic complexity is 7-7+2 = 2.
Or M= P + 1, Where P = Number of predicate nodes (node that contains condition)
M=1+1= 2.
17
Software Testing (22518) CO5I
1.7 Black Box Testing: Requirement Based Testing, Boundary Value Analysis, Equivalence
Partitioning.
Positive Testing
Positive Testing is a testing process where the system validated against the valid input data.
In this testing tester always checks for only valid sets of values and checks if an application behaves
as expected with its expected inputs.
The main intention is to check whether software applications are not showing error when not
supposed to & showing error when supposed to. Keeping a positive point of view & only executing
the positive scenario. Positive Testing always tries to prove that a given product and project always
meets the requirements and specifications.
18
Software Testing (22518) CO5I
Negative Testing
Negative Testing is a testing process where the system validated against the invalid input data.
A negative test checks if an application behaves as expected with its negative inputs.
Such testing is to be carried out keeping a negative point of view & only execute the test cases for
only invalid sets of input data.
The main reason behind Negative testing is to check the stability of the software application against
the different variety of incorrect data.
For example
1. #include<stdio.h>
2. void main()
3. {
4. int i , fact=1, n;
5. printf(“enter the number “);
6. scanf(“%d”,&n);
7. for(i =1 ;i <=n;i++)
8. fact = fact * i;
9. printf (“the factorial of a number is ”%d”, fact);
10. }
The boundary condition in the above example is for the integer variable:- -32,768 to 32,767
Sub-Boundary Conditions
Sub-boundaries are internal to the software, Not noticeable by an end user but still need to be
checked by the software tester. These are known as sub-boundary conditions or internal boundary
conditions.
Enter Character to find its ASCII value
19
Software Testing (22518) CO5I
Equivalence Partitioning
Equivalence partitioning is the process of methodically reducing the huge (infinite) set of
possible test cases into a much smaller, but still equally effective, set. Divides the input domain
of the program into classes of data from which the test cases can be divided.
For example
Input text box accept only number between 4 to 10
4 to 10 - Valid input
More than 10- Invalid input
Less than 4 - Invalid input
Choose test case based on these partition and also select boundary test cases as 3,4,10,11.
Consider the possibilities for entering a filename in the standard Save As dialog box
A Windows filename can contain any characters except \ / : * ? “ < > and |.
Filenames can have from 1 to 255 characters. If you’re creating test cases for filenames, you will
have equivalence partitions for valid characters, invalid characters, valid length names, names that
are too short, and names that are too long.
20
Software Testing (22518) CO5I
Example
Three types of customers are defined: a regular customer, a silver customer, and a gold
customer (these types are assigned by the amount of business the customer does with the print
shop over a 12-month period).
A regular customer receives normal print rates and delivery. A silver customer gets an 8 percent
discount on all quotes and is placed ahead of all regular customers in the job queue. A gold
customer gets a 15 percent reduction in quoted prices and is placed ahead of both regular and silver
customers in the job queue. A special discount of x percent in addition to other discounts can be
applied to any customer’s quote at the discretion of management
State Testing
The other side of software testing is to verify the program's logic flow through its various states.
A software state is a condition or mode that the software is currently in. Windows Paint program
in the pencil drawing state. This is the initial state in which the software starts. Notice that the
pencil tool is selected, the cursor looks like a pencil, and a fine line is used to draw onscreen.
The same program in the airbrush state. In this state, the airbrush tool is selected, airbrush sizes are
provided, the cursor looks like a spray-paint can, and drawing results in a spray-paint look.
22
Software Testing (22518) CO5I
23
Software Testing (22518) CO5I
24
Software Testing (22518) CO5I
• Warranty/registration card that the customer fills out and sends in to register the software.
• End User License Agreement
• Installation and setup instructions
• User’s manual
• Online help
• Samples, examples, and templates
• Error messages
Important Questions
1. Define software Quality Assurance and software Quality Control.
2. Define following terms-Failure, Error, Defect and Bug.
3. State process of Black box testing with labeled diagram? List any four techniques of black
box testing.
4. Enlist the objectives of software testing.
5. Design any four boundary value test cases for textbox which accept numbers from 1-999.
6. Define Static testing and Dynamic testing.
7. Differentiate between Verification and Validation.
8. Apply equivalence partitioning on application which display result on basis of percentage
obtained in exam.
9. Define White box testing and explain any two techniques of white box testing.
10. Write down the criteria when to start and when to stop testing.
11. Describe the use of decision table in black box testing with the help of suitable example.
12. Design test cases for railway reservation system.
13. Design test cases for hostel admission form of your institute.
14. Explain Static White Box Testing techniques in detail.
15. Differentiate between White box testing and black box testing.
25