Unit6 Software Testing

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

Unit 4: Software testing

What is Software Testing?

Software Testing is a method to assess the functionality of the software


program. The process checks whether the actual software matches the
expected requirements and ensures the software is bug-free. The purpose of
software testing is to identify the errors, faults, or missing requirements in
contrast to actual requirements. It mainly aims at measuring the specification,
functionality, and performance of a software program or application.

Software testing can be divided into two steps:


1. Verification: It refers to the set of tasks that ensure that the software
correctly implements a specific function. It means “Are we building the
product right?”.
2. Validation: It refers to a different set of tasks that ensure that the software
that has been built is traceable to customer requirements. It means “Are we
building the right product?”

Importance of Software Testing:


 Defects can be identified early : Software testing is important because if there
are any bugs they can be identified early and can be fixed before the
delivery of the software.
 Improves quality of software : Software Testing uncovers the defects in the
software, and fixing them improves the quality of the software.
 Increased customer satisfaction : Software testing ensures reliability,
security, and high performance which results in saving time, costs, and
customer satisfaction.
 Helps with scalability: Software testing type non-functional testing helps to
identify the scalability issues and the point where an application might stop
working.
 Saves time and money: After the application is launched it will be very
difficult to trace and resolve the issues, as performing this activity will incur
more costs and time. Thus, it is better to conduct software testing at regular
intervals during software development.

Benefits of Software Testing

 Product quality: Testing ensures the delivery of a high-quality product as the

errors are discovered and fixed early in the development cycle.


 Customer satisfaction: Software testing aims to detect the errors or

vulnerabilities in the software early in the development phase so that the


detected bugs can be fixed before the delivery of the product. Usability
testing is a type of software testing that checks the application for how easily
usable it is for the users to use the application.
 Cost-effective: Testing any project on time helps to save money and time for

the long term. If the bugs are caught in the early phases of software testing,
it costs less to fix those errors.
 Security: Security testing is a type of software testing that is focused on

testing the application for security vulnerabilities from internal or external


sources.
Software Testing can be broadly classified into 3 types:

1. Functional Testing: Functional testing is a type of software testing that


validates the software systems against the functional requirements. It is
performed to check whether the application is working as per the software’s
functional requirements or not. Various types of functional testing are Unit
testing, Integration testing, System testing, Smoke testing, and so on.
2. Non-functional Testing: Non-functional testing is a type of software testing
that checks the application for non-functional requirements like performance,
scalability, portability, stress, etc. Various types of non-functional testing are
Performance testing, Stress testing, Usability Testing, and so on.
3. Maintenance Testing: Maintenance testing is the process of changing,
modifying, and updating the software to keep up with the customer’s needs.
It involves regression testing that verifies that recent changes to the code
have not adversely affected other previously working parts of the software.

1. Black Box Testing: Black box technique of testing in which the tester doesn’t
have access to the source code of the software and is conducted at the
software interface without any concern with the internal logical structure of
the software known as black-box testing.
Black-box testing is a type of software testing in which the tester is not
concerned with the internal knowledge or implementation details of the
software, but rather focuses on validating the functionality based on the
provided specifications or requirements.

Black box testing is a technique of software testing which examines the


functionality of software without peering into its internal structure or coding. The
primary source of black box testing is a specification of requirements that is stated
by the customer.

In this method, tester selects a function and gives input value to examine its
functionality, and checks whether the function is giving expected output or not. If
the function produces correct output, then it is passed in testing, otherwise failed.
The test team reports the result to the development team and then tests the next
function. After completing testing of all functions if there are severe problems, then
it is given back to the development team for correction.

Generic steps of black box testing


o The black box test is based on the specification of requirements, so it is examined in the
beginning.
o In the second step, the tester creates a positive test scenario and an adverse test
scenario by selecting valid and invalid input values to check that the software is
processing them correctly or incorrectly.
o In the third step, the tester develops various test cases such as decision table, all pairs
test, equivalent division, error estimation, cause-effect graph, etc.
o The fourth phase includes the execution of all test cases.
o In the fifth step, the tester compares the expected output against the actual output.
o In the sixth and final step, if there is any flaw in the software, then it is cured and tested
again.

Test procedure
The test procedure of black box testing is a kind of process in which the tester has
specific knowledge about the software's work, and it develops test cases to check the
accuracy of the software's functionality.

It does not require programming knowledge of the software. All test cases are designed
by considering the input and output of a particular function.A tester knows about the
definite output of a particular input, but not about how the result is arising. There are
various techniques used in black box testing for testing like decision table technique,
boundary value analysis technique, state transition, All-pair testing, cause-effect graph
technique, equivalence partitioning technique, error guessing technique, use case
technique and user story technique. All these techniques have been explained in detail
within the tutorial.

Test cases
Test cases are created considering the specification of the requirements. These test
cases are generally created from working descriptions of the software including
requirements, design parameters, and other specifications. For the testing, the test
designer selects both positive test scenario by taking valid input values and adverse test
scenario by taking invalid input values to determine the correct output. Test cases are
mainly designed for functional testing but can also be used for non-functional testing.
Test cases are designed by the testing team, there is not any involvement of the
development team of software.

Techniques Used in Black Box Testing


Decision Table Decision Table Technique is a systematic approach where various input combinations
Technique and their respective system behavior are captured in a tabular form. It is appropriate
for the functions that have a logical relationship between two and more than two
inputs.

Boundary Boundary Value Technique is used to test boundary values, boundary values are
Value those that contain the upper and lower limit of a variable. It tests, while entering
Technique boundary value whether the software is producing correct output or not.

State State Transition Technique is used to capture the behavior of the software application
Transition when different input values are given to the same function. This applies to those
Technique types of applications that provide the specific number of attempts to access the
application.

All-pair Testing All-pair testing Technique is used to test all the possible discrete combinations of
Technique values. This combinational method is used for testing the application that uses
checkbox input, radio button input, list box, text box, etc.

Cause-Effect Cause-Effect Technique underlines the relationship between a given result and all the
Technique factors affecting the result.It is based on a collection of requirements.

Equivalence Equivalence partitioning is a technique of software testing in which input data divided
Partitioning into partitions of valid and invalid values, and it is mandatory that all partitions must
Technique exhibit the same behavior.

Error Guessing Error guessing is a technique in which there is no specific method for identifying the
Technique error. It is based on the experience of the test analyst, where the tester uses the
experience to guess the problematic areas of the software.

Use Case Use case Technique used to identify the test cases from the beginning to the end of
Technique the system as per the usage of the system. By using this technique, the test team
creates a test scenario that can exercise the entire software based on the functionality
of each function from start to end.

White Box Testing


White box technique of testing in which the tester is aware of the internal
workings of the product, has access to its source code, and is conducted by
making sure that all internal operations are performed according to the
specifications is known as white box testing.
The box testing approach of software testing consists of black box testing and white box
testing. We are discussing here white box testing which also known as glass box
is testing, structural testing, clear box testing, open box testing and transparent
box testing. It tests internal coding and infrastructure of a software focus on checking
of predefined inputs against expected and desired outputs. It is based on inner workings
of an application and revolves around internal structure testing.

Developers do white box testing. In this, the developer will test every line of the code of
the program. The developers perform the White-box testing and then send the
application or the software to the testing team, where they will perform the black box
testing and verify the application along with the requirements and identify the bugs and
sends it to the developer.

The developer fixes the bugs and does one round of white box testing and sends it to
the testing team. Here, fixing the bugs implies that the bug is deleted, and the particular
feature is working fine on the application.

The white box testing contains various tests, which are as follows:

o Path testing
o Loop testing
o Condition testing
o Testing based on the memory perspective
o Test performance of the program
And test all the independent paths implies that suppose a path from main() to function
G, first set the parameters and test if the program is correct in that particular path, and
in the same way test all other paths and fix the bugs.

Loop testing
In the loop testing, we will test the loops such as while, for, and do-while, etc. and also
check for ending condition if working correctly and if the size of the conditions is
enough.

For example: we have one program where the developers have given about 50,000
loops.

{
while(50,000)
……
……
}

We cannot test this program manually for all the 50,000 loops cycle. So we write a small
program that helps for all 50,000 cycles, as we can see in the below program, that test P
is written in the similar language as the source code program, and this is known as a
Unit test. And it is written by the developers only.
Test P
{
……
…… }

As we can see in the below image that, we have various requirements such as 1, 2, 3, 4.
And then, the developer writes the programs such as program 1,2,3,4 for the parallel
conditions. Here the application contains the 100s line of codes.

The developer will do the white box testing, and they will test all the five programs line
by line of code to find the bug. If they found any bug in any of the programs, they will
correct it. And they again have to test the system then this process contains lots of time
and effort and slows down the product release time.

Now, suppose we have another case, where the clients want to modify the requirements,
then the developer will do the required changes and test all four program again, which
take lots of time and efforts.

These issues can be resolved in the following ways:

In this, we will write test for a similar program where the developer writes these test
code in the related language as the source code. Then they execute these test code,
which is also known as unit test programs. These test programs linked to the main
program and implemented as programs.

Therefore, if there is any requirement of modification or bug in the code, then the
developer makes the adjustment both in the main program and the test program and
then executes the test program.

Condition testing
In this, we will test all logical conditions for both true and false values; that is, we will
verify for both if and else condition.

For example:

if(condition) - true
{
…..
……
……
}
else - false
{
…..
……
……
}

The above program will work fine for both the conditions, which means that if the
condition is accurate, and then else should be false and conversely.

Testing based on the memory (size) perspective


The size of the code is increasing for the following reasons:

o The reuse of code is not there: let us take one example, where we have four programs
of the same application, and the first ten lines of the program are similar. We can write
these ten lines as a discrete function, and it should be accessible by the above four
programs as well. And also, if any bug is there, we can modify the line of code in the
function rather than the entire code.
o The developers use the logic that might be modified. If one programmer writes code
and the file size is up to 250kb, then another programmer could write a similar code
using the different logic, and the file size is up to 100kb.
o The developer declares so many functions and variables that might never be used in
any portion of the code. Therefore, the size of the program will increase.

For example,

A Int a=15;
Int b=20;
String S= "Welcome";
….
…..
…..
….
…..
Int p=b;
Create user()
{
……
……
….. 200's line of code
}

In the above code, we can see that the integer a has never been called anywhere in the
program, and also the function Create user has never been called anywhere in the code.
Therefore, it leads us to memory consumption.

We cannot remember this type of mistake manually by verifying the code because of
the large code. So, we have a built-in tool, which helps us to test the needless variables
and functions. And, here we have the tool called Rational purify.

Suppose we have three programs such as Program P, Q, and R, which provides the input
to S. And S goes into the programs and verifies the unused variables and then gives the
outcome. After that, the developers will click on several results and call or remove the
unnecessary function and the variables.

o The developer does not use the available in-built functions; instead they write the full
features using their logic. Therefore, it leads us to waste of time and also postpone the
product releases.
Test the performance (Speed, response time) of the
program
The application could be slow for the following reasons:

o When logic is used.


o For the conditional cases, we will use or & and adequately.
o Switch case, which means we cannot use nested if, instead of using a switch case.

As we know that the developer is performing white box testing, they understand that
the code is running slow, or the performance of the program is also getting deliberate.
And the developer cannot go manually over the program and verify which line of the
code is slowing the program.

To recover with this condition, we have a tool called Rational Quantify, which resolves
these kinds of issues automatically. Once the entire code is ready, the rational quantify
tool will go through the code and execute it. And we can see the outcome in the result
sheet in the form of thick and thin lines.

Here, the thick line specifies which section of code is time-consuming. When we double-
click on the thick line, the tool will take us to that line or piece of code automatically,
which is also displayed in a different color. We can change that code and again and use
this tool. When the order of lines is all thin, we know that the presentation of the
program has enhanced. And the developers will perform the white box testing
automatically because it saves time rather than performing manually.

Test cases for white box testing are derived from the design phase of the software
development lifecycle. Data flow testing, control flow testing, path testing, branch
testing, statement and decision coverage all these techniques used by white box testing
as a guideline to create an error-free software.

White box testing follows some working steps to make testing manageable and easy to
understand what the next task to do. There are some basic steps to perform white box
testing.

Generic steps of white box testing


o Design all test scenarios, test cases and prioritize them according to high priority
number.
o This step involves the study of code at runtime to examine the resource utilization, not
accessed areas of the code, time taken by various methods and operations and so on.
o In this step testing of internal subroutines takes place. Internal subroutines such as
nonpublic methods, interfaces are able to handle all types of data appropriately or not.
o This step focuses on testing of control statements like loops and conditional statements
to check the efficiency and accuracy for different data inputs.
o In the last step white box testing includes security testing to check all possible security
loopholes by looking at how the code handles security.

Reasons for white box testing


o It identifies internal security holes.
o To check the way of input inside the code.
o Check the functionality of conditional loops.
o To test function, object, and statement at an individual level.

Advantages of White box testing


o White box testing optimizes code so hidden errors can be identified.
o Test cases of white box testing can be easily automated.
o This testing is more thorough than other testing approaches as it covers all code paths.
o It can be started in the SDLC phase even without GUI.

AD

Disadvantages of White box testing


o White box testing is too much time consuming when it comes to large-scale
programming applications.
o White box testing is much expensive and complex.
o It can lead to production error because it is not detailed by the developers.
o White box testing needs professional programmers who have a detailed knowledge and
understanding of programming language and implementation.

Techniques Used in White Box Testing

Data Flow Data flow testing is a group of testing strategies that examines the control flow of
Testing programs in order to explore the sequence of variables according to the sequence of
events.

Control Flow Control flow testing determines the execution order of statements or instructions of
Testing the program through a control structure. The control structure of a program is used
to develop a test case for the program. In this technique, a particular part of a large
program is selected by the tester to set the testing path. Test cases represented by
the control graph of the program.

Branch Branch coverage technique is used to cover all branches of the control flow graph. It
Testing covers all the possible outcomes (true and false) of each condition of decision point
at least once.

Statement Statement coverage technique is used to design white box test cases. This technique
Testing involves execution of all statements of the source code at least once. It is used to
calculate the total number of executed statements in the source code, out of total
statements present in the source code.

Decision This technique reports true and false outcomes of Boolean expressions. Whenever
Testing there is a possibility of two or more outcomes from the statements like do while
statement, if statement and case statement (Control flow statements), it is considered
as decision point because there are two outcomes either true or false.

Unit Testing
Unit testing involves the testing of each unit or an individual component of the software
application. It is the first level of functional testing. The aim behind unit testing is to
validate unit components with its performance.

A unit is a single testable part of a software system and tested during the development
phase of the application software.

The purpose of unit testing is to test the correctness of isolated code. A unit component
is an individual function or code of the application. White box testing approach used for
unit testing and usually done by the developers.

Whenever the application is ready and given to the Test engineer, he/she will start
checking every component of the module or module of the application independently
or one by one, and this process is known as Unit testing or components testing.

Why Unit Testing?


In a testing level hierarchy, unit testing is the first level of testing done before
integration and other remaining levels of the testing. It uses modules for the testing
process which reduces the dependency of waiting for Unit testing frameworks, stubs,
drivers and mock objects are used for assistance in unit testing.
Some crucial reasons are listed below:

o Unit testing helps tester and developers to understand the base of code that
makes them able to change defect causing code quickly.
o Unit testing helps in the documentation.
o Unit testing fixes defects very early in the development phase that's why there is
a possibility to occur a smaller number of defects in upcoming testing levels.
o It helps with code reusability by migrating code and test cases.

Example of Unit testing


Let us see one sample example for a better understanding of the concept of unit testing:
For the amount transfer, requirements are as follows:

1. Amount transfer

1.1 From account number (FAN)→ Text Box

1.1.1 FAN→ accept only 4 digit

1.2 To account no (TAN)→ Text Box

1.2.1 TAN→ Accept only 4 digit

1.3 Amount→ Text Box

1.3.1 Amount → Accept maximum 4 digit

1.4 Transfer→ Button

1.4.1 Transfer → Enabled

1.5 Cancel→ Button

1.5.1 Cancel→ Enabled

Below are the application access details, which is given by the customer

o URL→ login Page


o Username/password/OK → home page
o To reach Amount transfer module follow the below

Loans → sales → Amount transfer

While performing unit testing, we should follow some rules, which are as follows:

o To start unit testing, at least we should have one module.


o Test for positive values
o Test for negative values
o No over testing
o No assumption required

When we feel that the maximum test coverage is achieved, we will stop the testing.
Now, we will start performing the unit testing on the different components such as

o From account number(FAN)


o To account number(TAN)
o Amount
o Transfer
o Cancel

Unit Testing Tools


We have various types of unit testing tools available in the market, which are as follows:

o NUnit
o JUnit
o PHPunit
o Parasoft Jtest
o EMMA

Unit Testing Techniques:


Unit testing uses all white box testing techniques as it uses the code of software
application:
o Data flow Testing
o Control Flow Testing
o Branch Coverage Testing
o Statement Coverage Testing
o Decision Coverage Testing

Advantages and disadvantages of unit


testing
The pros and cons of unit testing are as follows:

Advantages
o Unit testing uses module approach due to that any part can be tested without waiting
for completion of another parts testing.
o The developing team focuses on the provided functionality of the unit and how
functionality should look in unit test suits to understand the unit API.
o Unit testing allows the developer to refactor code after a number of days and ensure the
module still working without any defect.

Disadvantages
o It cannot identify integration or broad level error as it works on units of the code.
o In the unit testing, evaluation of all execution paths is not possible, so unit testing is not
able to catch each and every error in a program.
o It is best suitable for conjunction with other testing activities.

Integration testing
Integration testing is the second level of the software testing process comes after unit
testing. In this testing, units or individual components of the software are tested in a
group. The focus of the integration testing level is to expose defects at the time of
interaction between integrated components or units.
Once all the components or modules are working independently, then we need to check
the data flow between the dependent modules is known as integration testing.

Let us see one sample example of a banking application, as we can see in the below
image of amount transfer.

o First, we will login as a user P to amount transfer and send Rs200 amount, the
confirmation message should be displayed on the screen as amount transfer
successfully. Now logout as P and login as user Q and go to amount balance page and
check for a balance in that account = Present balance + Received Balance. Therefore, the
integration test is successful.
o Also, we check if the amount of balance has reduced by Rs200 in P user account.
o Click on the transaction, in P and Q, the message should be displayed regarding the data
and time of the amount transfer.

Guidelines for Integration Testing


o We go for the integration testing only after the functional testing is completed on each
module of the application.
o We always do integration testing by picking module by module so that a proper
sequence is followed, and also we don't miss out on any integration scenarios.
o First, determine the test case strategy through which executable test cases can be
prepared according to test data.
o Examine the structure and architecture of the application and identify the crucial
modules to test them first and also identify all possible scenarios.
o Design test cases to verify each interface in detail.
o Choose input data for test case execution. Input data plays a significant role in testing.
o If we find any bugs then communicate the bug reports to developers and fix defects and
retest.
o Perform positive and negative integration testing.

Types of Integration Testing


Integration testing can be classified into two parts:

o Incremental integration testing


o Non-incremental integration testing
Incremental Approach
In the Incremental Approach, modules are added in ascending order one by one or
according to need. The selected modules must be logically related. Generally, two or
more than two modules are added and tested to determine the correctness of functions.
The process continues until the successful testing of all the modules.

Incremental integration testing is carried out by further methods:

o Top-Down approach
o Bottom-Up approach

Top-Down Approach

The top-down testing strategy deals with the process in which higher level modules are
tested with lower level modules until the successful completion of testing of all the
modules. Major design flaws can be detected and fixed early because critical modules
tested first. In this type of method, we will add the modules incrementally or one by one
and check the data flow in the same order.
In the top-down approach, we will be ensuring that the module we are adding is
the child of the previous one like Child C is a child of Child B and so on as we can
see in the below image:
Advantages:

o Identification of defect is difficult.


o An early prototype is possible.

Disadvantages:

o Due to the high number of stubs, it gets quite complicated.


o Lower level modules are tested inadequately.
o Critical Modules are tested first so that fewer chances of defects.

Bottom-Up Method

The bottom to up testing strategy deals with the process in which lower level modules
are tested with higher level modules until the successful completion of testing of all the
modules. Top level critical modules are tested at last, so it may cause a defect. Or we can
say that we will be adding the modules from bottom to the top and check the data
flow in the same order.

In the bottom-up method, we will ensure that the modules we are adding are the
parent of the previous one as we can see in the below image:
Advantages

o Identification of defect is easy.


o Do not need to wait for the development of all the modules as it saves time.

Disadvantages

o Critical modules are tested last due to which the defects can occur.
o There is no possibility of an early prototype.

Non- incremental integration testing


We will go for this method, when the data flow is very complex and when it is difficult to
find who is a parent and who is a child. And in such case, we will create the data in any
module bang on all other existing modules and check if the data is present. Hence, it is
also known as the Big bang method.
Advantages:

o It is convenient for small size software systems.

Disadvantages:

o Identification of defects is difficult because finding the error where it came from
is a problem, and we don't know the source of the bug.
o Small modules missed easily.
o Time provided for testing is very less.
o We may miss to test some of the interfaces.
System Testing
System Testing includes testing of a fully integrated software system. Generally, a
computer system is made with the integration of software (any software is only a single
element of a computer system). The software is developed in units and then interfaced
with other software and hardware to create a complete computer system.

System testing is a series of different type of tests with the purpose to exercise and
examine the full working of an integrated software computer system against
requirements.

Types of System Testing


System testing is divided into more than 50 types, but software testing companies
typically uses some of them. These are listed below:

Regression Testing
Regression testing is performed under system testing to confirm and identify that if
there's any defect in the system due to modification in any other part of the system. It
makes sure, any changes done during the development process have not introduced a
new defect and also gives assurance; old defects will not exist on the addition of new
software over the time.

Load Testing
Load testing is performed under system testing to clarify whether the system can work
under real-time loads or not.

Functional Testing
Functional testing of a system is performed to find if there's any missing function in the
system. Tester makes a list of vital functions that should be in the system and can be
added during functional testing and should improve quality of the system.

Migration Testing
Migration testing is performed to ensure that if the system needs to be modified in new
infrastructure so it should be modified without any issue.

Usability Testing
The purpose of this testing to make sure that the system is well familiar with the user
and it meets its objective for what it supposed to do.

Recovery Testing
Recovery testing of a system is performed under system testing to confirm reliability,
trustworthiness, accountability of the system and all are lying on recouping skills of the
system. It should be able to recover from all the possible system crashes successfully.

Software and Hardware Testing


This testing of the system intends to check hardware and software compatibility. The
hardware configuration must be compatible with the software to run it without any
issue. Compatibility provides flexibility by providing interactions between hardware and
software.

You might also like