0% found this document useful (0 votes)
5 views16 pages

Unit4_SE

Software testing is the process of evaluating software to ensure it meets requirements and is free from defects, offering benefits like reduced costs and improved quality. It includes various types such as unit testing, integration testing, acceptance testing, and regression testing, each with specific purposes and tools. Additionally, testing strategies like black box and white box testing, as well as static testing, play crucial roles in identifying issues early and maintaining software quality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

Unit4_SE

Software testing is the process of evaluating software to ensure it meets requirements and is free from defects, offering benefits like reduced costs and improved quality. It includes various types such as unit testing, integration testing, acceptance testing, and regression testing, each with specific purposes and tools. Additionally, testing strategies like black box and white box testing, as well as static testing, play crucial roles in identifying issues early and maintaining software quality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Software Testing

Software Testing Software testing is the process of evaluating and verifying that a software
product or application functions as expected, meets requirements, and is free from errors or
defects

Benefits of Software Testing:


• Reduced development costs:
Identifying bugs early in the development process is less expensive to fix than later on.
• Improved software quality:
Thorough testing ensures the software meets the expected standards and requirements.
• Increased user satisfaction:
A well-tested product is more likely to be reliable, user-friendly, and meet user needs.
• Enhanced project success:
Effective testing minimizes risks related to software quality, security, and performance,
contributing to project success.

What is Unit Testing?


• Unit testing is a form of software testing where individual units of code are tested in isolation.
• A "unit" can be a function, a method, a class, or any other smallest testable part of the code.
• The purpose is to ensure that each unit behaves as expected, independently of other parts of
the application

Why is Unit Testing Important?


• Early bug detection:
Unit tests help identify and fix defects early in the development process, which is more efficient
and cost-effective than fixing bugs later.
• Improved code quality:
Unit tests encourage modular design and make the codebase more structured and easier to
maintain.
• Facilitates refactoring:
A comprehensive set of unit tests allows developers to make changes to the codebase with
confidence, knowing that they won't introduce regressions.
• Enables test-driven development (TDD):
With TDD, developers write tests before the code, which helps clarify requirements and guides
the development process.

Examples of Unit Testing Tools:


• JUnit: A popular unit testing framework for Java.
• Jest: A unit testing framework for JavaScript, often used in Node.js projects.
• NUnit: A unit testing framework for .NET languages.
• PHPUnit: A unit testing framework for PHP.
• unittest and pytest: Built-in and widely used unit testing frameworks in Python.

Integration testing is a software testing method where different modules or


components of a system are combined and tested as a group to ensure they work together seamlessly

Key aspects of integration testing:


• Purpose:
To detect and resolve issues that arise from the interactions between different parts of a
software system.
• Scope:
Involves testing the combined functionality of multiple modules, often after they have been
individually tested (unit testing).
• Goal:
To ensure that the different components communicate and exchange data correctly, and that
the overall system behaves as expected.
• Types:
• Top-down: Testing starts with the top-level module and progressively integrates lower-level
modules.
• Bottom-up: Testing starts with the lowest-level modules and progressively integrates higher-level
modules.
• Incremental: Integrating modules one at a time and testing the system after each integration.
• Big Bang: Integrating all modules at once and then testing the entire system.
• Mixed: A combination of top-down and bottom-up approaches.
Tools:
Tools like Selenium, SoapUI, and Cucumber can be used to automate integration tests.

Acceptance testing is a formal testing process where end-users or stakeholders evaluate


a software product to ensure it meets their needs and requirements before it's released

Purpose and Importance:


• Ensuring User Needs Are Met:
Acceptance testing verifies that the software aligns with the user's expectations and that it's
usable and functional in real-world scenarios.
• Catching Issues Early:
Identifying problems during this phase is more cost-effective than fixing them after the software
is released.
• Validating Requirements:
It confirms that the software fulfills the agreed-upon specifications and business requirements.
• Improving User Experience:
Acceptance testing helps ensure the software is easy to use and provides a positive user
experience.
• Reducing Post-Release Problems:
By addressing issues early, acceptance testing minimizes the risk of post-release bugs, recalls,
and customer dissatisfaction.

Types of Acceptance Testing:


• User Acceptance Testing (UAT):
This is the most common type, where end-users test the software.
• Operational Acceptance Testing (OAT):
This focuses on the software's readiness for the operational environment, including aspects
like reliability, maintainability, and compatibility.
• Business Acceptance Testing (BAT):
This verifies that the software aligns with the business's goals and objectives.
• Contract Acceptance Testing (CAT):
This involves testing the software against specific contractual requirements.

Regression testing is a crucial software testing practice that ensures


existing functionality remains intact after new changes, bug fixes, or enhancements are made.

Purpose:
• Maintaining Functionality:
Regression testing ensures that new code changes don't break or negatively impact previously
working features.
• Identifying Regressions:
It helps detect "regressions," which are unintended side effects or bugs introduced by new
code.
• Quality Assurance:
By verifying that existing functionality is preserved, regression testing contributes to the overall
quality and reliability of the software.
• Cost-Effective:
Identifying and fixing regressions early in the development process is more cost-effective than
waiting until later stages.

How it works:
• Test Suite Execution:
Regression testing involves re-running a set of pre-defined test cases, often referred to as the
"regression test suite".
• Test Case Selection:
The test suite typically includes tests that cover critical functionalities and areas where changes
are likely to introduce issues.
• Verification of Results:
The results of the tests are compared with the expected outcomes to identify any discrepancies
or regressions.
• Automated Testing:
Regression testing

Why is it important?
• Reduced Risk: Regression testing helps minimize the risk of introducing bugs or breaking
existing functionality during development.
• Increased Confidence: It builds confidence in the stability and reliability of the software.
• Improved Software Quality: By ensuring that new changes don't introduce regressions,
regression testing contributes to overall software quality.

Testing Strategies
There are many primary elements that are required to make the product testing lucid
and hassle-free. Every element has its own specific utility that helps a lot with
software testing and delivering the expected functionality as per the SRS
document as much as possible. Stubs and Drivers are two such elements that play a
very crucial role while testing; they replace the modules that haven’t been developed
yet but are still needed in the testing of other modules against expected functionality
and features.

What are Stubs?


Stubs are developed by software developers to use them in place of modules, if the
respective modules aren’t developed, missing in developing stage, or are unavailable
currently while Top-down testing of modules. A Stub simulates module which has all
the capabilities of the unavailable module. Stubs are used when the lower-level
modules are needed but are unavailable currently.
Stubs are divided into four basic categories based on what they do :
• Shows the traced messages,
• Shows the displayed message if any,
• Returns the corresponding values that are utilized by modules,
• Returns the value of the chosen parameters(arguments) that were used by the
testing modules.
What are Drivers?
Drivers serve the same purpose as stubs, but drivers are used in Bottom-up integration
testing and are also more complex than stubs. Drivers are also used when some
modules are missing and unavailable at time of testing of a specific module because
of some unavoidable reasons, to act in absence of required module. Drivers are used
when high-level modules are missing and can also be used when lower-level modules
are missing.
Ex : Suppose, you are told to test a website whose corresponding primary modules
are, where each of them is interdependent on each other, as follows:
• Module-A : Login page website,
• Module-B : Home page of the website
• Module-C : Profile setting
• Module-D : Sign-out page
It’s always considered good practice to begin development of all modules parallelly
because as soon as each gets developed they can be integrated and could be tested
further as per their corresponding interdependencies order with a module. But in some
cases, if any one of them is in developing stage or not available in the testing process
of a specific module, stubs or drivers could be used instead.
Assume Module-A is developed. As soon as it’s developed, it undergoes testing, but
it requires Module-B, which isn’t developed yet. So in this case, we can use the Stubs
or Drivers that simulate all features and functionality that might be shown by
actual Module-B. So, we can conclude that Stubs and drivers are used to fulfill the
necessity of unavailable modules. Similarly, we may also use Stubs or Drivers in place
of Module-C and Module-D if they are too not available.
Do both drivers and Stubs serve the same functionality?
Yes, we can say both serve the same feature and are used in the absence of
a module(M1) that has interdependencies with an other module(M2) that is need to
be test, so we use drivers or stubs in order to fulfill module(M1)’s unavailability’s and
to serve its functionality.
Difference between Stubs and Drivers
S.No. Stubs Drivers

Stubs are used in Top-Down Integration Drivers are used in Bottom-Up


1.
Testing. Integration Testing.

Stubs are basically known as a “called While, drivers are the “calling
2. programs” and are used in the Top- program” and are used in bottom-up
down integration testing. integration testing.

Stubs are similar to the modules of the


While drivers are used to invoking the
3. software, that are under development
component that needs to be tested.
process.
S.No. Stubs Drivers

While drivers are mainly used in place


Stubs are basically used in the of high-level modules and in some
4.
unavailability of low-level modules. situation as well as for low-level
modules.

Stubs are taken into use to test the Whereas the drivers are used if the
5. feature and functionality of the main module of the software isn’t
modules. developed for testing.

The stubs are taken into concern if The drivers are taken into concern if
testing of upper-levels of the modules testing of lower-levels of the modules
6.
are done and the lower-levels of the are done and the upper-levels of the
modules are under developing process. modules are under developing process.

Stubs are used when lower-level of Drivers are used when higher-level of
modules are missing or in a partially modules are missing or in a partially
7.
developed phase, and we want to test the developed phase, and we want to test
main module. the lower(sub)- module.

What is Black Box Testing?


Black-Box Testing is a Type of Software Testing in which the tester is not
concerned with the software’s internal knowledge or implementation details but
rather focuses on validating the functionality based on the
provided specifications or requirements.
Black Box Testing

The following are the several categories of black box testing:


1. Functional Testing
2. Regression Testing
3. Nonfunctional Testing (NFT)
What is White Box Testing?
White-box Testing is a Software Testing Technique that involves testing the
internal structure and workings of a Software Application. The tester has access to
the source code and uses this knowledge to design test cases that can verify the
correctness of the software at the code level.
It is also called Glass Box Testing or Clear Box Testing or Structural Testing.
White Box Testing

White box testing can be done for different purposes. The three main types are:
1. Unit Testing
2. Integration Testing
3. Regression Testing

Black Box Testing Vs White Box Testing


Parameters Black Box Testing White Box Testing

Black Box Testing is a way of White Box Testing is a way of


software testing in which the testing the software in which the
internal structure or the program or tester has knowledge about the
the code is hidden and nothing is internal structure or the code or
Definition known about it. the program of the software.
Parameters Black Box Testing White Box Testing

Black box testing is mainly


White box testing is mainly
focused on testing the functionality
focused on ensuring that the
of the software, ensuring that it
Testing internal code of the software is
meets the requirements and
correct and efficient.
objectives specifications.

Black box testing uses methods White box testing uses methods
like Equivalence like Control Flow
Partitioning, Boundary Value Testing, Data Flow
Analysis, and Error Guessing to Testing and Statement
Testing methods create test cases. Coverage Testing.

Black box testing does not require


any knowledge of the internal White box testing requires
workings of the software, and can knowledge of programming
be performed by testers who are languages, software architecture
not familiar with programming and design patterns.
Knowledge level languages.

White box testing is used for


Black box testing is generally used
testing the software at the unit
for testing the software at the
level, integration level and
functional level.
Scope system level.

Implementation of code is not Code implementation is


Implementation needed for black box testing. necessary for white box testing.

Black Box Testing is mostly done White Box Testing is mostly


Done By by software testers. done by software developers.

Black Box Testing can be referred


White Box Testing is the inner
to as outer or external software
or the internal software testing.
Terminology testing.

Black Box Testing is a functional White Box Testing is a


Testing Level test of the software. structural test of the software.
Parameters Black Box Testing White Box Testing

Black Box testing can be initiated White Box testing of software is


Testing based on the requirement started after a detail design
Initiation specifications document. document.

No knowledge of programming is It is mandatory to have


Programming required. knowledge of programming.

Black Box Testing is the behavior White Box Testing is the logic
Testing Focus testing of the software. testing of the software.

Black Box Testing is applicable to White Box Testing is generally


the higher levels of testing of applicable to the lower levels of
Applicability software. software testing.

Alternative Black Box Testing is also called White Box Testing is also called
Names closed testing. as clear box testing.

Time Black Box Testing is least time White Box Testing is most time
Consumption consuming. consuming.

Suitable for
Black Box Testing is not suitable White Box Testing is suitable
Algorithm or preferred for algorithm testing. for algorithm testing.
Testing

Data domains along with inner


Can be done by trial and error ways
or internal boundaries can be
and methods.
Approach better tested.

Search something on google by By input to check and verify


Example using keywords loops

It is comparatively more
It is less exhaustive as compared to
exhaustive than black box
white box testing.
Exhaustiveness testing.

Note: Regression Testing can indeed be a part of both black-box and white-box testing
What is Static Testing?
Static Testing also known as Verification testing or Non-execution testing is a
type of Software Testing method that is performed in the early stage of
development to avoid errors as it is easier to find sources of failures and it
can be fixed easily.

Need for Static Testing


1. Increased software size: Static testing is required to get free from bugs
in the early stages of development as with testing activity the size of the
software increases which is difficult to handle due to a reduction in the
productivity of the code coverage.
2. Dynamic testing is expensive: Dynamic testing is more expensive than
static testing as dynamic testing uses test cases that have been created
in the initial stages and there is also a need to preserve the
implementation and validation of the test cases which takes a lot of time
from test engineers:
3. Dynamic testing is time-consuming: Static testing is required as
dynamic testing is a time-consuming process.
4. Bugs detection at early stages: Static testing is helpful as it finds bugs
at early stages, while dynamic testing finds bugs at later stages which
makes it time-consuming and costly to fix the bugs.
5. Improvement of development productivity: Static testing helps to
identify bugs early in the software development thus it helps to reduce the
flaws during production and increase development productivity.
Objectives of Static Testing
Below are some of the objectives of static testing:
1. Decreases Flaws: Static testing will decrease the flaws in production as
the bugs will be detected early in the software development.
2. Saves Time: Early detection of the bugs helps to save a lot of time, effort,
and cost that will be required to fix the bugs.
3. Easy Bug Fixing: Static testing is used to identify the bugs early in
software development, where it is quite easy to fix the bugs.
4. Quality Improvement: Enhance overall software quality of the software
product by ensuring the compliance with the coding standards and best
practices.
5. Cost Efficiency: Static testing helps to reduce the cost associated with
dynamic testing by catching defects early.
Features Tested in Static Testing
Static testing involves testing the following things:
1. Unit Test Cases: It ensures test cases are complete, written in the correct
manner, and follow the specified standards.
2. Business Requirements Document (BRD): It verifies that all business
requirements are clearly mentioned in the documentation.
3. Use Cases: It examines the use cases so that they accurately represent
user interactions with the system.
4. Prototype: It reviews the prototype to make sure that it accurately
represents the main design and functionality.
5. System Requirements: It check the system requirements document for
complete accuracy.
6. Test Data: It reviews the test data to ensure it is complete and covers all
possible input scenarios.
7. Traceability Matrix Document: This ensures that all requirements are
mapped to corresponding test cases.
8. Training Guides: It reviews training materials to make sure that they
accurately reflect the system functionality and user procedures.
9. Performance Test Scripts: It examines performance test scripts to ensure
they cover all critical performance aspects.
Static Testing Techniques
There are mainly two types of techniques used in Static Testing:

1. Review
In static testing, the review is a process or technique that is performed to find
potential defects in the design of the software. It is a process to detect and
remove errors and defects in the different supporting documents like
software requirements specifications. People examine the documents and
sorted out errors, redundancies, and ambiguities. Review is of four types:
1. Informal: In an informal review the creator of the documents put the
contents in front of an audience and everyone gives their opinion and thus
defects are identified in the early stage.
2. Walkthrough: It is basically performed by an experienced person or
expert to check the defects so that there might not be problems further in
the development or testing phase.
3. Peer review: Peer review means checking documents of one another to
detect and fix defects. It is basically done in a team of colleagues.
4. Inspection: Inspection is basically the verification of documents by the
higher authority like the verification of software requirement specifications
(SRS).
2. Static Analysis
Static Analysis includes the evaluation of the code quality that is written by
developers. Different tools are used to do the analysis of the code and
comparison of the same with the standard. It also helps in following
identification of the following defects:
1. Unused variables.
2. Dead code.
3. Infinite loops.
4. Variable with an undefined value.
5. Wrong syntax.
Static Analysis is of three types:
1. Data Flow: Data flow is related to the stream processing.
2. Control Flow: Control flow is basically how the statements or instructions
are executed.
3. Cyclomatic Complexity: Cyclomatic complexity defines the number of
independent paths in the control flow graph made from the code or
flowchart so that a minimum number of test cases can be designed for
each independent path.
How Static Testing is Performed?
Below are the steps that can be followed to perform static testing:
1. Planning: This step involves defining what needs to be tested, setting
objectives, determining the scope of testing, and preparing a testing
strategy. This should involve identifying the software components to be
tested, developing the testing methods, and identifying the tools to be
tested.
2. Prepare artifacts: In this step, necessary artifacts like source codes,
design documents, requirement documents, and test cases are prepared.
3. Perform static analysis: Static analysis is conducted in this phase where
the code is reviewed and analyzed for compliance with coding standards,
code quality, and security issues using specialized static analysis tools
without executing the code.
4. Perform code reviews: Code reviews are performed where a small team
of experts systematically reviews the code and finds potential errors using
various methods.
5. Report and document bugs: Bugs identified during static testing are
reported and documented.
6. Analyze results: The results collected during static testing are analyzed
to determine the quality of the software product.
Benefits of Static Testing
Below are some of the benefits of static testing:
1. Early defect detection: Static testing helps in early defect detection
when they are most easy and cost-effective to fix.
2. Prevention of common issues: Static testing helps to fix common
issues like syntax errors, null pointer exceptions, etc. Addressing these
issues early in development helps the teams to avoid problems later.
3. Improved code quality: Static testing helps to make sure that the code is
easy to maintain and well-structured. This leads to a higher quality code.
4. Reduced costs: Early bug detection in static testing helps to fix them
early in the development thus saving time, effort, and cost.
5. Immediate feedback: Static testing provides immediate evaluation and
feedback on the software during each phase while developing the
software product.
6. Helps to find exact bug location: Static testing helps to find the exact
bug location as compared to dynamic testing.
Limitations of Static Testing
Below are some of the limitations of static testing:
1. Detect Some Issues: Static testing may not uncover all issues that could
arise during runtime. Some defects may appear only during dynamic
testing when the software runs.
2. Depends on the Reviewer’s Skills: The effectiveness of static testing
depends on the reviewer’s skills, experience, and knowledge.
3. Time-consuming: Static testing can be time-consuming when working on
large and complex projects.
4. No Runtime Environment: It is conducted without executing the code.
This means it cannot detect runtime errors such as memory leaks,
performance issues, etc.
5. Prone to Human Error: Static testing is prone to human error due to
manual reviews and inspections techniques being used.
Best Practices for Static Testing
Below are some of the best practices for static testing:
1. Define Clear Objectives: Establish the objectives and scope of static
testing early in the project.
2. Develop Checklist: Create a checklist for reviews and coding standards
that align with the industry best practices and specific project
requirements.
3. Focus on High-Risk Areas: Prioritize static testing on high-risk areas of
the codebase that are more likely to contain defects.
4. Team Training: Provide training to the team members on static testing
techniques, tools, and best practices. Ensure everyone understands how
to perform static testing.
5. Prevent Test Execution Delays: Time and cost can be managed and
reduced if the test execution can be delayed.
6. Track Review Activities: It is good to plan the review activities and track
them as walkthroughs and reviews are usually merged into peer reviews.
7. Keep Process Formal: For efficient static testing, it is very important to
keep the process and project culture formal.
8. Regular Tool Updates: Keep static testing tools up to date to ensure
they can effectively detect the new types of issues.
Static Testing Tools
Some of the most commonly used static testing tools are:
1. Checkstyle
Checkstyle is a static analysis tool that helps developers to write Java code
and automates the process of checking Java code.
Features:
• It can verify the code layout and formatting issues.
• It can help to identify the method design problems and class design
problems.
• It is a highly configured tool that can support almost any coding standard
like Google Java Style, and Sun code conventions.
2. Soot
Soot is a Java optimization framework that has several analysis and
transformation tools.
Features:
• It can detect unnecessary code and thus improve the overall code quality.
• It is a framework for analyzing and transforming Java and Android
applications to test aspects like named modules and modular jar files,
automatic modules, exploded modules, etc.
3. SourceMeter
SourceMeter is a static testing tool for static source code analysis of various
programming languages like C/ C++, Java, C#, Python, and RPG Projects.
Features:
• It helps in the easy identification of vulnerable spots of the system under
development from the source code.
• It can analyze code in multiple programming languages and generates
reports that help developers to make informed decisions.
• The output of analysis and quality of analyzed source code can be used
to enhance the product.
4. Lint
Lint is a static analysis tool that scans code to flag programming errors and
bugs.
Features:
• It helps enforce coding standards and prevent errors and bugs in the
code.
• It helps to identify and correct common code mistakes without having to
run the application.
5. SonarQube
SonarQube is a static testing open-source tool to inspect code quality
continuously.
Features:
• It analyses and identifies the technical debt, bugs, and vulnerabilities
across different programming languages.
• It provides support for 29 languages and analyzes the quality of all the
languages in your projects.
• It has features like custom rules, integration with code repositories,
detailed code reports, and extensible plugins.

You might also like