SOFTWARE TESTING
AND AUTOMATION
    Course objectives:
• To understand the basics of software testing.
• To learn how to do testing and planning effectively.
• To build test cases and execute them.
• To focus on wide aspects of testing and understand
  multiple facts of testing.
• To get an insight about test automation and the tools
  used for test automation.
                         Unit-1
 FOUNDATIONS OF SOFTWARE TESTING
Why do we test Software? Black-Box Testing and
White-Box Testing, Software Testing Life Cycle, V-
model of Software Testing, Program Correctness and
Verification, Reliability versus Safety, Failures, Errors
and Faults (Defects), Software Testing Principles,
Program Inspections, Stages of Testing: Unit Testing,
Integration Testing, System Testing.
Why do we test software?
• The goal of software testing is to find errors, gaps, or missing
  requirements in comparison to the actual requirements.
• Quality Assurance.
• Satisfaction of the customer.
• Enhancing the development process.
• Determining the performance of the software.
• Easy while adding new features.
              Software Testing
§   Testing of software means assessing or
    Measuring the software to determine its
    QUALITY.
§   Area of testing is one of the key process areas
    of project life cycle in ensuring the QUALITY
    of the software.
§   Software testing is the process of evaluating
    and verifying that a software product or
    application does what it is supposed to do.
                                              5
Various Testing Techniques:
• Structural & Functional
• Verification &Validation
• Static & dynamic
• Black box & White box Testing
Levels of Testing:
Level of testing   Testing Techniques
• Unit Testing     Structural Testing
• Integration      Structural & functional
• System           Functional & Risk based
• Acceptance       Functional & Risk based
Black Box Testing:
• Black box testing refers to a software testing method where the
  SUT (Software under Test) functionality is tested without
  worrying about its details of implementation, internal path
  knowledge and internal code structure of the software.
                              Black box
• Black box testing are beneficial for the end users who wish
  to perform software verification
• Focuses on testing the complete functionality of the system
  as well as its behavior.
 Techniques used in Black box Testing:
 Boundary value analysis:
   • It is used to test boundary values , they are those that contain
      the upper and lower limit of a variable.it test whether the
      software is producing correct output or not.
Equivalence partitioning:
   • In this technique the input data divided into partions of valid and
    invalid values.
 Cause effect graphing:
   •     This techniques establishs the relationship between logical input
   called cause and corresponding output called effect.
Types:
   1. Functional
   2. Non functional
   3. Regression
    Tools used for Black box testing:
    • Appium
    • Selenium
    • Microsoft Coded UI
    • Applitools
    • HP QTP
     Advantages:
•     The tester does not need to have more functional knowledge or
  programming skills to implement the Black Box Testing.
•      It is efficient for implementing the tests in the larger system.
•     Tests are executed from the user’s or client’s point of view.
White box Testing:
• White box testing is a form of application testing that provides the
 tester with complete knowledge of the application being tested, including
 access to source code and design documents.
Working process :
Input: Requirements, Functional specifications, design documents,
      source code.
Processing: Performing risk analysis to guide through the entire process.
Proper test planning: Designing test cases so as to cover the entire code.
Output: Preparing final report of the entire testing process.
 Testing techniques:
 Statement coverage: In this technique, the aim is to traverse all
 statements at least once. Hence, each line of code is tested. In the case
 of a flowchart, every node must be traversed at least once.
Branch Coverage: In this technique, test cases are designed so that
each branch from all decision points is traversed at least once. In a
flowchart, all edges must be traversed at least once.
Condition Coverage: In this technique, all individual conditions must be
covered as shown in the following
 example:
READ X, Y
IF(X == 0 || Y == 0)
PRINT ‘0’
#TC1 – X = 0, Y = 55
#TC2 – X = 5, Y = 0
Multiple Condition Coverage: In this technique, all the possible
combinations of the possible outcomes of conditions are tested at least
once. Let’s consider the following example:
READ X, Y
IF(X == 0 || Y == 0)
PRINT ‘0’
#TC1: X = 0, Y = 0
#TC2: X = 0, Y = 5
#TC3: X = 55, Y = 0
#TC4: X = 55, Y = 5
Loop Testing: Loops are widely used and these are fundamental to many
algorithms hence, their testing is very important. Errors often occur at the
beginnings and ends of loops.
Types:
         Simple loops
         Nested loops
         Concatenated loops
Tools required for White box Testing:
PyUnit
Sqlmap
Nmap
Parasoft Jtest
Nunit
  Advantages:
 • White box testing is thorough as the entire code and structures are
   tested.
 • Removing errors and helps in removing extra lines of code.
 • It can start at an earlier stage as it doesn’t require any interface.
 • Easy to automte.
SOFTWARE TESTING LIFE CYCLE:
• The Software Testing Life Cycle (STLC) is a systematic approach to
  testing a software application to ensure that it meets the requirements
  and is free of defects.
• It is a process that follows a series of steps or phases, and each
  phase has specific objectives and deliverables.
• The main goal of the STLC is to identify and document any defects
  or issues in the software application as early as possible in the
  development process
Planning
           Requirement
            gathering
                     Designing
                                 Coding
                                          Testing
                                              Deployment
                                                     Maintenance
Stages of STLC:
1.   Project Planning
2.   Gathering Requirements & Analysis
3.   Design
4.   Coding or Implementation
5.   Testing
6.   Deployment
7.   Maintenance
Project planning:
     • In this phase, we identify the activities and resources which would
       help to meet the testing objectives.
 • During planning, we also try to identify the metrics and the method of
   gathering and tracking those metrics.
Gathering Requirements & Analysis:
 • In this phase quality assurance team understands the requirements
   like what is to be tested.
 • Identifying any missing or incomplete requirements.
Designing:
 • This phase defines “HOW” to test.
This phase involves the following tasks:
 •   Identify and get the test data.
 •   Identify and set up the test environment.
 •   Create the requirement traceability metrics.
 •   Create test coverage metrics.
Coding or Implementation:
 • Implement or create the code based on the software application.
• Before finalizing the test case, It is important to carry out a review to
   ensure the correctness of the test cases.
Testing:
• The primary purpose of the Test Phase is to determine whether the
   automated system/application software is ready for implementation.
Deployment:
• Once the testing is done, and the product is ready for deployment, it
  is released for customers to use.
 Maintenance:
• In this phase of SDLC where the developed product is taken care of.
• According to the changing user end environment or technology, the
  software is updated timely.
V- MODEL OF SOFTWARE TESTING:
• The V-model is a type of SDLC model where process executes in a
  sequential manner in V-shape.
• It is based on the idea of a “V” shape, with the two legs of the “V”
  representing the progression of the software development process
• V-Model contains Verification phases on one side and Validation phases
  on the other side. Verification and Validation process is joined by coding
  phase in V-shape. Thus it is known as V-Model.
                           h a se
              a t i o   np
    r i f i c
 Ve
Val
    id   atio
              np
                    has
                       e
Verification: It involves a static analysis method (review) done without
executing code. It is the process of evaluation of the product development
process to find whether specified requirements meet.
Validation: It involves dynamic analysis method (functional, non-
functional), testing is done by executing code. Validation is the process to
classify the software after the completion of the development process to
determine whether the software meets the customer expectations and
requirements.
Verification phase:
Requirement Analysis: This phase contains detailed communication with
the customer to understand their requirements and expectations.
System Design:This phase contains the system design and the complete
hardware and communication setup for developing product.
Architectural Design:The data transfer and communication between the
internal modules and with the outside world (other systems) is in this
phase.
Module Design: In this phase the system breaks down into small
modules. The detailed design of modules is specified, also known as
Low-Level Design (LLD).
Validation phase:
Unit Testing: Unit Test Plans are developed during module design phase.
These Unit Test Plans are executed to eliminate bugs at code.
Integration testing: The modules are integrated and the system is tested.
Integration testing is performed on the Architecture design phase. This test
verifies the communication of modules among themselves.
System Testing: System testing test the complete application with its
functionality, inter dependency, and communication. It tests the functional
and non-functional requirements of the developed application.
Acceptance Testing : This testing verifies that the delivered system meets
user’s requirement and system is ready for use in real world.
When to use V-Model?
• When the requirement is well defined and not ambiguous.
• The V-shaped model should be used for small to medium-sized projects
  where requirements are clearly defined and fixed.
• The V-shaped model should be chosen when sample technical resources
  are available with essential technical expertise.
Advantages (Pros) of V-Model:
• Easy to Understand.
• Testing Methods like planning, test designing happens well before
  coding.
• This saves a lot of time. Hence a higher chance of success over the
  waterfall model.
• Avoids the downward flow of the defects.
• Works well for small plans where requirements are easily understood.
Disadvantages (Cons) of V-Model:
• Very rigid and least flexible.
• Not good for a complex project.
• Software is developed during the implementation stage, so no early
  prototypes of the software are produced.
• If any changes happen in the midway, then the test documents along
  with the required documents, has to be updated.
Program correctness and Verification:
• The focus of software testing is to run the candidate program on
  selected input data and check whether the program behaves correctly
  with respect to its specification.
• The behavior of the program can be analyzed only if we know what is a
  correct behavior; hence the study of correctness is an integral part of
  software testing.
 • The study of program correctness leads to analyze candidate
   programs at arbitrary levels of granularity.
 • It leads to make assumptions on the behavior of the program at
   specific stages in its execution.
•     The same assumptions can be checked at run-time during testing, giving
     us valuable information as we try to diagnose the program or establish
     its correctness.
Reliability versus Safety:
                             Reliability:
    • Software Reliability means Operational reliability. It is described as the
      ability of a system or component to perform its required functions under
      static conditions for a specific period.
    • Software reliability is also defined as the probability that a software
      system fulfills its assigned task in a given environment for a
      predefined number of input cases, assuming that the hardware and the
      input are free of error.
• Software Reliability is an essential connect of software quality,
  composed with functionality, usability, performance, serviceability,
  capability, installability, maintainability, and documentation.
                               Safety:
• software system safety optimizes system safety in the design,
  development, use, and maintenance of software systems and their
  integration with safety-critical hardware systems in an operational
  environment.
Goals:
• In complex systems where there are many interactions involved, the
  safety-critical functionality should be identified and thoroughly analyzed.
 • The number of safety critical interfaces are kept low to avoid injury
   or death.
 • Safety attributes are to be addressed as part of all the levels of
   software testing.
Failures VS Errors VS Bugs VS Faults(Defects):
 • In general these all are sounds same. But in software testing, there is a
   conflict in the usage of these terms.
 What is Failure?
 • Many defects lead to the software's failure, which means that a
   loss specifies a fatal issue in software/ application or in its module,
   which makes the system unresponsive or broken.
 • In other words, we can say that if an end-user detects an issue in the
   product, then that particular issue is called a failure.
What is Error?
• The Problem in code leads to errors, which means that a mistake can
  occur due to the developer's coding error as the developer misunderstood
  the requirement or the requirement was not defined correctly.
What is Bug?
• In software testing, a bug is the informal name of defects, which means
  that software or application is not working as per the requirement.
• When we have some coding error, it leads a program to its breakdown,
  which is known as a bug.
What is Fault?
• The fault may occur in software because it has not added the code for
  fault tolerance, making an application act up.
A fault may happen in a program because of the following reasons:
 i. Lack of resources
 ii. An invalid step
 iii. Inappropriate data definition
       SOFTWARE TESTING PRINCIPLES:
   • Software testing is a procedure of implementing software or the
     application to identify the defects or bugs.
   • For testing an application or software, we need to follow some
     principles to make our product defects free, and that also helps the test
     engineers to test the software with their effort and time.
The seven essential principles of software testing are,
1.Testing shows the presence of defects:
  • The goal of software testing is to make the software failfree. Software
    testing reduces the presence of defects.
  •   Even multiple testing can never ensure that software is 100% bug-free.
      Testing can reduce the number of defects but not remove all defects.
 2.Exhaustive testing is not possible:
  • Exhaustive testing is impossible means the software can never test at
    every test case.
  • It can test only some test cases and assume that the software is correct
    and it will produce the correct output in every test case.
•    If the software will test every test case then it will take more cost,
    effort, time,etc.,
3.Early Testing:
•    To find the defect in the software, early test activity shall be started.
    The defect detected in the early phases of SDLC will be very less
    expensive.
•   Testing will perform at the requirement analysis phase.
4.Defect clustering:
• The defect clustering defined that throughout the testing process, it can
  detect the numbers of bugs which are correlated to a small number of
  modules.
5.Pesticide paradox:
 • This principle defined that if we are executing the same set of test cases
    again and again over a particular time, then these kinds of the test will
    not be able to find the new bugs in the software or the application.
6.Testing is context-dependent:
 • states that we have multiple fields such as e-commerce websites,
   commercial websites, and so on are available in the market.
 •    To check this type of application, we will take the help of various
     kinds of testing, different technique, approaches, and multiple
     methods. Therefore, the testing depends on the context of the
     application.
7.Absence of errors fallacy:
• Once the application is completely tested and there are no bugs identified
  before the release, so we can say that the application is 99 percent
  bug-free.
• But there is the chance when the application is tested beside the incorrect
  requirements, identified the flaws, and fixed them on a given period
  would not help as testing is done on the wrong specification, which does
  not apply to the client's requirements.
Program Inspections:
• Software program inspection is a process in which other developers or
  team members review the code written by a developer to identify
  potential errors or areas for improvement.
• This process can help improve the overall quality of the software by
  identifying and resolving faults early in the development process.
                  STAGES OF TESTING:
                      1. Unit testing
                      2. Integration testing
                      3. System testing
1.Unit testing:
• Unit testing involves the testing of each unit or an individual
  component of the software application.
• A unit is a single testable part of a software system and tested
  during the development phase
•    Unit Testing of the software product is carried out during the
    development of an application.
• An individual component may be either an individual function or a
  procedure. Unit Testing is typically performed by the developer.
• 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.
 Objective of Unit Testing:
1) To isolate a section of code.
2) To verify the correctness of the code.
3) To test every function and procedure.
4) To fix bugs early in the development cycle and to save costs.
5) To help the developers to understand the code base and enable them to
   make changes quickly.
6) To help with code reuse.
Unit Testing Tools:
 • Nunit
 • Junit
 • PHPunit
 • Jtest&EMMA
Unit Testing Techniques:
 •   Data flow Testing
 •   Control Flow Testing
 •   Branch Coverage Testing
 •   Statement Coverage Testing
 •   Decision Coverage Testing
Types:
  1. Manual
  2. Automated
 Advantages:
 • It improves design.
• Unit testing allows the developer to refactor code after a number of days
  and ensure the module still working without any defect.
• Unit testing uses module approach due to that any part can be tested
  without waiting for completion of another parts testing.
• Reduces Cost of Testing
Disadvantages:
• 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.
• It requires more time for maintenance when the source code is changed
  frequently.
•    Evaluation of all execution paths is not possible, so unit testing is not
    able to catch each and every error in a program.
2.Integration testing:
• It is the process of testing the interface between two software units or
  modules. It focuses on determining the correctness of the interface.
 • Integration testing is a software testing technique that focuses on verifying
    the interactions and data exchange between different components or
    modules of a software application.
Integration Testing Techniques:
    1. Black boox testing
    2. White box testing
Types:
 1) Incremental integration testing
 2) Non-incremental integration testing
Incremental Approach:
• In the Incremental Approach, modules are added in ascending order
  one by one or according to need.
• Two or more than two modules are added and tested to determine the
  correctness of functions.
 Top down method:
• 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.
• In this type of method, we will add the modules incrementally or one
  by one and check the data flow in the same order.
Advantages:
• Design defects can be found in the early
  stages.
• Separately debugged module.
Disadvantages:
• Critical Modules are tested first so that
  fewer chances of defects.
• It is difficult to stub design.
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.
• It will add the modules from bottom to the top and check the data flow
  in the same order.
Advantages:
• Identification of defect is easy.
• Do not need to wait for the development of all the modules as it saves
  time.
Disadvantages:
• There is no possibility of an early prototype.
• The complexity that occurs when the system
  is made up of a large number of small
  subsystems.
Non- incremental Approach:
•   All the modules of the system are simply put together and tested. This
    approach is applicable only for very small systems.
• The main goal of this testing is to verify the overall functionality of the
  system and to identify any integration problems that arise when the
  components are combined.
Advantages:
• It is convenient for small systems
• Simple and straightforward approach.
• Can be completed quickly.
Disadvantages:
 • Not Good for long projects.
 • This may result in a lack of confidence in the development team.
 • This can lead to system failure and decreased user satisfaction.
 • Time provided for testing is very less.
3.System Testing:
 • It evaluates the overall functionality and performance of a complete and
   fully integrated software solution.
 • It tests if the system meets the specified requirements and check if it is
   suitable for delivery to the end-users.
System Testing Process:
   • Test Environment Setup: Create testing environment for the better
     quality testing.
   • Create Test Case: Generate test case for the testing process.
   • Create Test Data: Generate the data that is to be tested.
   • Execute Test Case: After the generation of the test case and the test
     data, test cases are executed.
   • Defect Reporting: Defects in the system are detected.
   • Regression Testing: It is carried out to test the side effects of the
     testing process.
   • Log Defects: Defects are fixed in this step.
   • Retest: If the test is not successful then again test is performed.
Types of System Testing:
Performance Testing: It is carried out to test the speed, scalability, stability
and reliability of the software product or application.
Load Testing: Load Testing is a type of software Testing which is carried out
to determine the behavior of a system or software product under extreme load.
Stress Testing: It will performed to check the robustness of the system under
the varying loads.
Scalability Testing: It will check the performance of a software application
or system in terms of its capability to scale up or scale down the number of
user request load.
Tools used in system testing:
 1.   Jmeter
 2.   Selenium
 3.   Appium
 4.   LoadRunner
 5.   SoapUI
Advantages:
• Verifies the overall functionality of the system.
• Improves system reliability and quality.
• Enhances the overall performance of the system.
• Increases user confidence and reduces risks.
Disadvantages:
• Can be impacted by changes made during development.
• Requires specialized skills.
• May require multiple test cycles to achieve desired results.
• Can be complex and challenging.