Software Engineer Notes Unit 4
Software Engineer Notes Unit 4
Software Testing
Software Testing is a method to check whether the actual software product
matches expected requirements and to ensure that software product
is Defect free. It identifying the correctness of software by considering its all
attributes (Reliability, Scalability, Portability, Re-usability, Usability).
The purpose of software testing is to identify errors, gaps or missing requirements
in contrast to actual requirements.
In simple terms, Software Testing means the Verification of Application Under Test
(AUT).
Testing is mandatory because it will be a dangerous situation if the software fails any of
time due to lack of testing. So, without testing software cannot be deployed to the end
user.
Need of Testing:
Starbucks was forced to close about 60 percent of stores in the U.S and
Canada due to software failure in its POS system. At one point, the store
served coffee for free as they were unable to process the transaction.
Some of Amazon’s third-party retailers saw their product price is reduced
to 1p due to a software glitch. They were left with heavy losses.
In 2015 fighter plane F-35 fell victim to a software bug, making it unable to
detect targets correctly.
China Airlines Airbus A300 crashed due to a software bug on April 26,
1994, killing 264 innocents live
In April of 1999, a software bug caused the failure of a $1.2 billion military
satellite launch, the costliest accident in history
Functional Testing
Non-Functional Testing or Performance Testing
Maintenance (Regression and Maintenance)
Unit Testing
Integration Testing
Smoke
UAT ( User Acceptance Testing)
Localization
Globalization
Interoperability and So on.
2. Non-Functional Testing:
It include-
Performance
Endurance
Load
Volume
Scalability
Usability and So on.
3. Maintenance:
It include-
This is not the complete list as there are more than 150 types of testing types
and still adding. Also, all testing types are applicable to all projects but depend
on the nature & scope of the project.
Testing Levels
The levels of software testing involve the different methodologies, which can be used
while we are performing the software testing.
1. Unit Testing
2. Integration Testing
3. System Testing
4. Acceptance Testing
1. Unit Testing
Unit testing is the first level of software testing, which is used to test if software modules
are satisfying the given requirement or not.
The first level of testing involves analyzing each unit or an individual component of
the software application. Unit testing is also the first level of functional testing.
2. Integration Testing
The second level of software testing is the integration testing. The integration testing
process comes after unit testing. It is mainly used to test the data flow from one
module or component to other modules.
In integration testing, the test engineer tests the units or separate components or
modules of the software in a group. We only go for the integration testing when the
functional testing has been completed successfully on each application module. It is
subdivided into the Top-Down Approach, Bottom-Up Approach, and Sandwich
Approach (Combination of Top-Down and Bottom-Up).
In simple words, we can say that integration testing aims to evaluate the accuracy of
communication among all the modules.
In system testing, we will go through all the necessary modules of an application and test
if the end features or the end business works fine, and test the product as a complete
system.
4. Acceptance Testing
The last and fourth level of software testing is acceptance testing, which is used to
evaluate whether a specification or the requirements are met as per its delivery.
The software has passed through three testing levels (Unit Testing, Integration Testing,
System Testing). Some minor errors can still be identified when the end-user uses the
system in the actual scenario.
In simple words, we can say that Acceptance testing is the squeezing of all the testing
processes that are previously done.
The acceptance testing is also known as User acceptance testing (UAT) and is done by
the customer before accepting the final product.
Alpha,
Beta &
Gamma Testing.
The inputs received by the system and the outputs or responses it produces are tested.
The term black box symbolizes a black outer covering of the application,
preventing testers from seeing its inner workings and compelling them to
examine only the end-user experience. Due to its nature, black box testing is
sometimes called specification-based testing, closed box testing, or opaque
box testing.
For the execution of this method, the tester or the person who will use this method must have
extensive knowledge of the technology used to develop the program.
The term white box signifies the application’s transparency, allowing the
tester to see through the outer box and into the inner code. White box testing
is leveraged to improve design, usability, and application security.
1. Verification: it refers to the set of tasks that ensure that the software
correctly implements a specific function.
2. Validation: it refers to a different set of tasks that ensure that the
software that has been built is traceable to customer requirements.
For example, if source code contains no control flow statement then its
cyclomatic complexity will be 1 and source code contains a single path in it.
Similarly, if the source code contains one if condition then cyclomatic
complexity will be 2 because there will be two paths one for true and the other
for false.
Method-01:
V (G) = E – N + 2
Where,
E – Number of edges
N – Number of Nodes
Method-02:
V (G) = P + 1
Where,
P = Number of predicate nodes (node that contains condition)
Method-03:
Steps to be followed:
The following steps should be followed for computing Cyclomatic complexity
and test cases design.
Step 1 – Construction of graph with nodes and edges from the code
Step 2 – Identification of independent paths
Once the basic set is formed, TEST CASES should be written to execute all
the paths.
Problem:
Calculate cyclomatic complexity for the given code-
IF A = 354
THEN IF B > C
THEN A = B
ELSE A = C
END IF
END IF
PRINT A
Solution-
We draw the following control flow graph for the given code-
Using the above control flow graph, the cyclomatic complexity may be calculated as-
Method-01:
*Cyclomatic Complexity*
= Total number of closed regions in the control flow graph + 1
=2+1
=3
Method-02:
*Cyclomatic Complexity*
=E–N+2
=8–7+2
=3
Method-03:
*Cyclomatic Complexity*
=P+1
=2+1
=3
Complex Code
10 – 20 Medium Testability
Medium Cost and Effort
Mutation Testing:
Step 1: Faults are introduced into the source code of the program by creating
many versions called mutants. Each mutant should contain a single fault, and
the goal is to cause the mutant version to fail which demonstrates the
effectiveness of the test cases.
Step 2: Test cases are applied to the original program and also to the mutant
program. A Test Case should be adequate, and it is tweaked to detect faults
in a program.
Step 4: If the original program and mutant programs generate the different
output, then that the mutant is killed by the test case. Hence the test case is
good enough to detect the change between the original and the mutant
program.
Step 5: If the original program and mutant program generate the same output,
Mutant is kept alive. In such cases, more effective test cases need to be
created that kill all mutants.
Mutation Score
The mutation score is defined as the percentage of killed mutants with the
total number of mutants.
Test cases are mutation adequate if the score is 100%. Experimental results
have shown that mutation testing is an effective approach for measuring the
adequacy of the test cases. But, the main drawback is that the high cost of
generating the mutants and executing each test case against that mutant
program.
For example, testing the music site behavior when there are millions of user
to download the song.
Stress Testing
Stress Testing is a type of software testing that verifies stability & reliability of
software application. The goal of Stress testing is measuring software on its
robustness and error handling capabilities under extremely heavy load
conditions and ensuring that software doesn’t crash under crunch situations. It
even tests beyond normal operating points and evaluates how software works
under extreme conditions.
To conduct Stress Testing, sometimes, massive data sets may be used which
may get lost during Stress Testing. Testers should not lose this security-
related data while doing stress testing.
The main purpose of stress testing is to make sure that the system recovers
after failure which is called as recoverability.
Debugging:
Software programs undergo heavy testing, updating, troubleshooting, and
maintenance during the development process. Usually, the software
contains errors and bugs, which are routinely removed. Debugging is the
process of fixing a bug in the software.
Corrective Maintenance
Corrective software maintenance is what one would typically associate with
the maintenance of any kind. Correct software maintenance addresses the
errors and faults within software applications that could impact various
parts of your software, including the design, logic, and code. These
corrections usually come from bug reports that were created by users or
customers – but corrective software maintenance can help to spot them
before your customers do, which can help your brand’s reputation.
Corrective maintenance aims to correct any remaining errors regardless of
where they may cause specifications, design, coding, testing, and
documentation, etc.
Adaptive maintenance:
Adaptive software maintenance becomes important when the environment
of your software changes. This can be brought on by changes to the
operating system, hardware, software dependencies, Cloud storage, or
even changes within the operating system.
Perfective maintenance:
Perfective software maintenance focuses on the evolution of requirements
and features that existing in your system. As users interact with your
applications, they may notice things that you did not or suggest new
features that they would like as part of the software, which could become
future projects or enhancements. Perfective software maintenance takes
over some of the work, both adding features that can enhance user
experience and removing features that are not effective and functional. This
can include features that are not used or those that do not help you to meet
your end goals.
Preventive maintenance:
Preventative software maintenance is looking into the future so that your
software can keep working as desired for as long as possible.
Law Description
Organizational stability The rate with which the software is developed remains
approximately constant and is independent of the
resources devoted to the software development.
Component Features
Request for additional functionality, error
User requirements correction, capability, and improvement in
maintainability.
Request for non-programming related
support.
Hardware platform.
Operational environment Software specifications.
Capturing requirements.
Maintenance process Variation in programming and working
practices.
Paradigm shift.
Error detection and correction.
Quality of documentation.
Software product Complexity of programs.
Program structure.
Staff turnover.
Software maintenance team Domain expertise.