Unit Testing
Unit Testing
tested. The purpose is to validate that each unit of the software performs as designed. A unit is
the smallest testable part of any software. It usually has one or a few inputs and usually a single
output.
Acceptance Testing: A level of the software testing process where a system is tested for
acceptability. The purpose of this test is to evaluate the system’s compliance with the
business requirements and assess whether it is acceptable for delivery.
System Testing: A level of the software testing process where a complete, integrated
system/software is tested. The purpose of this test is to evaluate the system’s compliance with
the specified requirements.
Integration Testing: A level of the software testing process where individual units are
combined and tested as a group. The purpose of this level of testing is to expose faults in the
interaction between integrated units.
Unit Testing: A level of the software testing process where individual units/components of a
software/system are tested. The purpose is to validate that each unit of the software performs
as designed.
Unit Testing is the first level of software testing and is performed prior to Integration Testing.
Manual
Automated
Unit testing is commonly automated but may still be performed manually. Software
Engineering does not favour one over the other but automation is preferred. A manual approach
to unit testing may employ a step-by-step instructional document.
Statement Coverage
Decision Coverage
Branch Coverage
Condition Coverage
Finite State Machine Coverage
Statement Coverage
Statement coverage is a white box test design technique which involves execution of all the
executable statements in the source code at least once. It is used to calculate and measure the
number of statements in the source code which can be executed given the requirements.
Statement coverage is used to derive scenario based upon the structure of the code under test.
In White Box Testing, the tester is concentrating on how the software works. In other words,
the tester will be concentrating on the internal working of source code concerning control
flow graphs or flow charts.
Generally in any software, if we look at the source code, there will be a wide variety of
elements like operators, functions, looping, exceptional handlers, etc. Based on the input to
the program, some of the code statements may not be executed. The goal of Statement
coverage is to cover all the possible path's, line, and statement in the code.
Scenario to calculate Statement Coverage for given source code. Here we are taking two
different scenarios to check the percentage of statement coverage for each scenario.
Source Code:
Scenario 1:
If A = 3, B = 9
The statements marked in yellow color are those which are executed as per the scenario
Scenario 2:
If A = -3, B = -9
The statements marked in yellow color are those which are executed as per the scenario.
But overall if you see, all the statements are being covered by 2nd scenario's considered. So
we can conclude that overall statement coverage is 100%.
1. Unused Statements
2. Dead Code
3. Unused Branches
Decision Coverage
Decision coverage reports the true or false outcomes of each Boolean expression. In this
coverage, expressions can sometimes get complicated. Therefore, it is very hard to achieve
100% coverage.
That's why there are many different methods of reporting this metric. All these methods focus
on covering the most important combinations. It is very much similar to decision coverage,
but it offers better sensitivity to control flow.
Demo(int a) {
If (a> 5)
a=a*3
Print (a)
}
Scenario 1:
Value of a is 2
The code highlighted in yellow will be executed. Here the "No" outcome of the decision If
(a>5) is checked.
Scenario 2:
Value of a is 6
The code highlighted in yellow will be executed. Here the "Yes" outcome of the decision If
(a>5) is checked.
1 2 2 50%
2 6 18 50%
Branch Coverage
In the branch coverage, every outcome from a code module is tested. For example, if the
outcomes are binary, you need to test both True and False outcomes.
It helps you to ensure that every possible branch from each decision condition is executed at
least a single time.
By using Branch coverage method, you can also measure the fraction of independent code
segments. It also helps you to find out which is sections of code don't have any branches.
To learn branch coverage, let's consider the same example used earlier
Demo(int a) {
If (a> 5)
a=a*3
Print (a)
}
1 2 2 50%
2 6 18 50%
Condition Coverage
Conditional coverage or expression coverage will reveal how the variables or subexpressions
in the conditional statement are evaluated. In this coverage expressions with logical operands
are only considered.
For example, if an expression has Boolean operations like AND, OR, XOR, which indicated
total possibilities.
Conditional coverage offers better sensitivity to the control flow than decision coverage.
Condition coverage does not give a guarantee about full decision coverage
TT
FF
TF
FT
Y=4
B=4
Unit tests help with code re-use. Migrate both your code and your tests to your new project.
Tweak the code till the tests run again.
Conformance Testing is defined as a software testing type that determines whether the system
complies with requirements of specifications and conditions, regulations and standards, etc.
along with its documentation. It is also called as Compliance Testing.
Conformance Testing is initiated by the management with total assurance about the team and
their understanding of standards, specifications, and procedures.
Features and Functionality supported by a software system is not the only concern. A
software application's performance like its response time, reliability, resource usage and
scalability do matter. The goal of Performance Testing is not to find bugs but to eliminate
performance bottlenecks.
Performance Testing is done to provide stakeholders with information about their application
regarding speed, stability, and scalability. More importantly, Performance Testing uncovers
what needs to be improved before the product goes to market. Without Performance Testing,
software is likely to suffer from issues such as: running slow while several users use it
simultaneously, inconsistencies across different operating systems and poor usability.
Interface Testing is defined as a software testing type which verifies whether the
communication between two different software systems is done correctly.
An interface is actually software that consists of sets of commands, messages, and other
attributes that enable communication between a device and a user.
To ensure that end-users or customer should not encounter any problem when using a
particular software product
To identify which application areas are usually accessed by end-users and to check its
user-friendliness as well.
To verify security requirements while communication propagates between the
systems
To check if a solution is capable to handle network failures between an application
server and website
Functional Testing is defined as a type of testing which verifies that each function of the
software application operates in conformance with the requirement specification. This testing
mainly involves black box testing and it is not concerned about the source code of the
application.
Each and every functionality of the system is tested by providing appropriate input, verifying
the output and comparing the actual results with the expected results.
The prime objective of Functional testing is checking the functionalities of the software
system. It mainly concentrates on -