Unit4_SE
Unit4_SE
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
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.
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 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.
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 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 is the behavior White Box Testing is the logic
Testing Focus testing of the software. testing of the software.
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
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.
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.