unit 3 SVVT
unit 3 SVVT
unit 3 SVVT
test generation
UNIT-3
TEST GENERATION
Test genera琀椀on in so昀琀ware tes琀椀ng is the process of crea琀椀ng a set of test cases or test scripts
that are speci昀椀cally designed to assess and verify the func琀椀onality, performance, security, or
other aspects of a so昀琀ware applica琀椀on or system. This process aims to ensure that the
so昀琀ware works correctly and meets its intended requirements. Test genera琀椀on can be done
manually or automated using various techniques and tools.
Genera琀椀ng test cases from so昀琀ware requirements is a fundamental step in the so昀琀ware
tes琀椀ng process. It ensures that the so昀琀ware meets the speci昀椀ed func琀椀onal and non-
func琀椀onal requirements and behaves as expected. Here's an explana琀椀on of how to generate
test cases from requirements in so昀琀ware tes琀椀ng:
1. Requirement Analysis:
Start by carefully reviewing and understanding the so昀琀ware requirements
documenta琀椀on. This may include func琀椀onal requirements, non-func琀椀onal
requirements, user stories, use cases, and any other relevant speci昀椀ca琀椀ons.
2. Iden琀椀fy Testable Scenarios:
Break down the requirements into speci昀椀c testable scenarios or test cases.
Each test case should focus on one par琀椀cular aspect or func琀椀onality of the
so昀琀ware.
3. Boundary Condi琀椀ons:
Pay special a琀琀en琀椀on to boundary condi琀椀ons, edge cases, and error handling
requirements within the requirements. These o昀琀en lead to cri琀椀cal defects
and should be tested thoroughly.
4. Posi琀椀ve and Nega琀椀ve Test Cases:
Create both posi琀椀ve test cases (valid inputs leading to expected results) and
nega琀椀ve test cases (invalid inputs leading to error condi琀椀ons) to ensure
comprehensive coverage.
5. Equivalence Par琀椀琀椀oning:
Apply equivalence par琀椀琀椀oning to group similar inputs and create test cases
that represent each par琀椀琀椀on. This helps reduce redundancy in your test
cases.
6. State Transi琀椀on Tes琀椀ng:
For systems with state-based behaviour, iden琀椀fy state transi琀椀on requirements
and design test cases to cover these transi琀椀ons.
7. Use Case Tes琀椀ng:
If you have use cases or user stories, create test cases that simulate how users
would interact with the so昀琀ware to achieve their goals.
8. Data-Driven Tes琀椀ng:
If the requirements involve data manipula琀椀on, create test cases with various
data sets to validate the so昀琀ware's handling of di昀昀erent data inputs.
9. Requirements Traceability:
Ensure that each test case is traceable back to the speci昀椀c requirement it is
tes琀椀ng. This helps in comprehensive test coverage and requirement
valida琀椀on.
10. Priority and Risk-Based Tes琀椀ng:
Priori琀椀ze test cases based on the cri琀椀cality of the func琀椀onality they cover and
the poten琀椀al risks associated with it. Focus on high-priority areas 昀椀rst.
11. Test Design Techniques:
U琀椀lize test design techniques such as boundary value analysis, decision
tables, state transi琀椀on diagrams, and equivalence class par琀椀琀椀oning to
systema琀椀cally create test cases.
12. Test Precondi琀椀ons and Postcondi琀椀ons:
De昀椀ne any precondi琀椀ons (condi琀椀ons that must be true before the test case
can be executed) and postcondi琀椀ons (expected outcomes or condi琀椀ons a昀琀er
the test case execu琀椀on) for each test case.
13. Nega琀椀ve Path Tes琀椀ng:
Ensure that you include test cases that follow nega琀椀ve paths, tes琀椀ng how the
so昀琀ware handles unexpected or erroneous inputs and situa琀椀ons.
By following these steps, you can systema琀椀cally generate test cases that cover the full
spectrum of requirements and ensure thorough tes琀椀ng of the so昀琀ware. This helps in
iden琀椀fying and addressing defects early in the development process, leading to a more
robust and reliable 昀椀nal product.
Moore Machines
A Moore State Machine is a type of state machine for modelling systems with a high degree
of uncertainty. In these systems, predic琀椀ng the exact sequence of future events is di昀케cult.
As a result, it is di昀케cult to determine the next event.
A Moore model captures this uncertainty by allowing the system to move from one state to
another based on the outcome of a random event.
A Moore model has many applica琀椀ons in both industry and academia. For example, it can be
used to predict when a system will fail or when certain events will occur with a high
probability (e.g., when there will be an earthquake).
It can also be used as part of an op琀椀miza琀椀on algorithm when dealing with uncertain inputs
(e.g., produce only 1% more product than standard).
In addi琀椀on, Moore models are o昀琀en used as rules for automa琀椀c control systems (e.g.,
medical equipment) that need to respond quickly and accurately without human
interven琀椀on.
Turing Machine
The Turing Machine consists of an input tape (with symbols on it), an internal tape (which
corresponds to memory), and an output tape (which contains the result).
A Turing Machine operates through a series of steps: it scans its input tape, reads out one
symbol at a 琀椀me from its internal tape, and then applies this symbol as a command (or
decision) to its output tape. For example: “If you see ‘X’ on the input tape, then print ‘Y’ on
the output tape.”
The input tape can be considered a 昀椀nite set of symbols, while the internal and output tapes
are in昀椀nite. The Turing Machine must read an en琀椀re symbol from its internal tape before it
can move its head to the next symbol on the input tape.
Once it has moved its head to the next symbol, it can read that symbol out of its internal
tape and then move to the next symbol on its input tape.
This process con琀椀nues un琀椀l no more input or output symbols are le昀琀 in the Turing Machine’s
internal or external tapes (at which point, it stops).
Business Decision-Making
Companies pair FSMs with their data strategy to explore the cause and e昀昀ect of business
scenarios to make informed business decisions.
Business scenarios are o昀琀en complex and unpredictable. There are many possible outcomes,
and each one impacts the business di昀昀erently.
A simula琀椀on allows you to try di昀昀erent business scenarios and see how each plays out. You
can then assess the risk and determine the best course of ac琀椀on.
So昀琀ware Design
Developers use state machines to model how a user interacts with the applica琀椀on. These
models are also helpful in modelling business logic 昀氀ow in the system.
In both cases, state machines help visualize the 昀氀ow of the applica琀椀on and organize the
code in a maintainable fashion.
State machines are o昀琀en used to improve the user experience, especially in apps with lots of
steps or where there’s a risk of user abandonment.
For example, a booking app might use a state machine to track the progress of a booking
and display a di昀昀erent set of 昀椀elds based on the stage of the booking.
While the booking process might be linear, the user experience can be improved by o昀昀ering
relevant 昀椀elds upfront and removing them as soon as they are no longer required.
You can think about this concept as having a conversa琀椀on with your users: you have a set of
ques琀椀ons you need to ask, but the order in which you ask them, and the 琀椀ming with which
you ask them, can have a signi昀椀cant impact on the user experience, and ul琀椀mately on your
company’s bo琀琀om line.
State machines help developers ensure their so昀琀ware is e昀케cient, scalable and
maintainable.
5. Nega琀椀ve Tes琀椀ng:
Nega琀椀ve tes琀椀ng with regular expressions involves ensuring that speci昀椀c
pa琀琀erns or formats are NOT present in the data.
Testers use regex to check that sensi琀椀ve informa琀椀on or prohibited content is
absent from text or logs.
6. Func琀椀onal Tes琀椀ng:
In func琀椀onal tes琀椀ng, regular expressions are employed to validate that
speci昀椀c pa琀琀erns or data formats are correctly processed and displayed by the
so昀琀ware.
For instance, regex can be used to verify that a text forma琀�ng feature in a
word processing applica琀椀on works as expected.
7. URL and Web Tes琀椀ng:
Regular expressions are valuable in web tes琀椀ng for valida琀椀ng URLs, web page
content, and data pa琀琀erns.
Testers use regex to check the structure of URLs, validate web page content,
and extract speci昀椀c data from web pages.
8. API Tes琀椀ng:
In API tes琀椀ng, regular expressions are used to verify the format and content
of API responses.
Testers apply regex to validate that API responses match prede昀椀ned pa琀琀erns
or that speci昀椀c error messages are returned.
9. Log Analysis:
Log analysis and monitoring bene昀椀t from regular expressions to 昀椀lter, search,
and parse log entries.
Testers use regex to search for speci昀椀c events, errors, or pa琀琀erns in log 昀椀les,
facilita琀椀ng debugging and issue detec琀椀on.
10. Load Tes琀椀ng and Performance Tes琀椀ng:
Regular expressions can be applied to load and performance tes琀椀ng to
validate server responses and response 琀椀mes.
Testers use regex to con昀椀rm that responses meet expected pa琀琀erns and that
response 琀椀mes are within acceptable limits under various load condi琀椀ons.
11. Security Tes琀椀ng:
In security tes琀椀ng, regular expressions help iden琀椀fy pa琀琀erns associated with
vulnerabili琀椀es or a琀琀acks.
Testers use regex to detect poten琀椀al security threats like SQL injec琀椀on, cross-
site scrip琀椀ng (XSS), or sensi琀椀ve data exposure in input data.
Regular expressions based tes琀椀ng is a versa琀椀le approach that can signi昀椀cantly improve the
quality, security, and reliability of so昀琀ware systems by ensuring data and behaviour
conformity to prede昀椀ned pa琀琀erns and standards. However, it's important for testers to have
a solid understanding of regex and carefully design test cases to cover various scenarios
e昀昀ec琀椀vely.
Test Selection
Test selec琀椀on in so昀琀ware tes琀椀ng is the process of choosing which test cases or test scenarios
to execute from a larger pool of available tests. This decision is made based on several
factors to ensure that the tes琀椀ng process is e昀昀ec琀椀ve, e昀케cient, and aligned with project
goals. Here's an explana琀椀on of test selec琀椀on in so昀琀ware tes琀椀ng:
1. Priori琀椀za琀椀on: Test cases are priori琀椀zed based on factors such as cri琀椀cality, risk, and
business impact. Cri琀椀cal func琀椀onali琀椀es or areas of the so昀琀ware that are more likely
to contain defects are given higher priority.
2. Resource Management: Test selec琀椀on considers available tes琀椀ng resources,
including 琀椀me, budget, and tes琀椀ng environments. It aims to make the best use of
these resources while achieving the desired test coverage.
3. Regression Tes琀椀ng: Test selec琀椀on includes regression tests, which are executed to
ensure that exis琀椀ng func琀椀onality remains intact a昀琀er code changes or updates.
Regression tests are crucial for maintaining so昀琀ware quality.
4. Coverage Goals: It aligns with coverage goals de昀椀ned for the tes琀椀ng phase. Coverage
can be measured in terms of code coverage (e.g., statement coverage, branch
coverage) or requirements coverage to ensure that all cri琀椀cal areas are adequately
tested.
5. Risk Assessment: Test selec琀椀on involves assessing the risks associated with di昀昀erent
parts of the so昀琀ware. High-risk areas are tested more rigorously to uncover poten琀椀al
defects early in the development cycle.
6. Tes琀椀ng Types and Levels: Di昀昀erent types of tes琀椀ng (e.g., unit tes琀椀ng, integra琀椀on
tes琀椀ng, system tes琀椀ng) and tes琀椀ng levels (e.g., component-level, system-level) may
require speci昀椀c test selec琀椀on strategies to address speci昀椀c goals and objec琀椀ves.
7. Feedback Loop: Test selec琀椀on is an itera琀椀ve process that considers feedback from
previous test runs. It adapts test selec琀椀on decisions based on the results and defects
found in earlier tes琀椀ng phases.
8. Requirements Alignment: It ensures that test cases align with so昀琀ware requirements
and user stories. Test selec琀椀on veri昀椀es that all speci昀椀ed func琀椀onali琀椀es and features
are adequately tested.
9. Automa琀椀on: Test automa琀椀on is leveraged to select and execute automated test
scripts e昀케ciently, especially for repe琀椀琀椀ve and 琀椀me-consuming test scenarios.
10. Con琀椀nuous Integra琀椀on/Con琀椀nuous Delivery (CI/CD) Integra琀椀on: In CI/CD pipelines,
test selec琀椀on is integrated to automa琀椀cally trigger relevant tests as part of the
con琀椀nuous integra琀椀on and deployment process.
11. Documenta琀椀on: Test selec琀椀on decisions are documented to provide traceability and
ra琀椀onale for why speci昀椀c tests were chosen, aiding in repor琀椀ng and audi琀椀ng e昀昀orts.
12. Exit Criteria: Clear exit criteria are de昀椀ned to determine when tes琀椀ng for a par琀椀cular
phase or cycle is complete. Test selec琀椀on ensures that these criteria are met.
E昀昀ec琀椀ve test selec琀椀on is crucial for achieving comprehensive tes琀椀ng while managing
constraints and resources e昀케ciently. It ensures that the most cri琀椀cal and high-impact test
cases are executed, leading to higher so昀琀ware quality and reliability.
1. Objec琀椀ve: Test case minimiza琀椀on aims to reduce the number of generated test cases
while maintaining or improving test coverage. It focuses on elimina琀椀ng redundancy
and op琀椀mizing the test suite.
2. Techniques:
Coverage-Based Minimiza琀椀on: Remove redundant test cases that cover the
same code paths, requirements, or states.
Dependency Analysis: Analyse test case dependencies and retain only the
most cri琀椀cal and independent ones.
Equivalence Class Par琀椀琀椀oning: Group similar test cases into equivalence
classes and select representa琀椀ve test cases from each class.
Pairwise Tes琀椀ng: Generate a subset of test cases that cover all pairwise
combina琀椀ons of input values, reducing the number of test cases.
3. Bene昀椀ts:
Reduces tes琀椀ng e昀昀ort, saving 琀椀me and resources.
Maintains or enhances test coverage, ensuring defect detec琀椀on.
Simpli昀椀es test suite maintenance and execu琀椀on.
2. Techniques:
Risk-Based Priori琀椀za琀椀on: Priori琀椀ze test cases based on their risk exposure,
cri琀椀cality, and poten琀椀al impact on the so昀琀ware.
Code Change Impact: Give higher priority to test cases that cover areas of the
code that have been recently modi昀椀ed.
Fault Proneness Analysis: Analyse historical defect data to priori琀椀ze test
cases in areas of the so昀琀ware that have been prone to defects.
Requirements-Based Priori琀椀za琀椀on: Priori琀椀ze test cases based on the
importance of verifying speci昀椀c requirements.
3. Bene昀椀ts:
Iden琀椀昀椀es and addresses cri琀椀cal defects early in the tes琀椀ng cycle.
Op琀椀mizes tes琀椀ng 琀椀me and resources by focusing on high-priority test cases.
Enhances overall so昀琀ware quality by addressing cri琀椀cal issues promptly.
Challenges:
Balancing the trade-o昀昀 between minimizing test cases and maintaining adequate
coverage can be challenging.
Iden琀椀fying the most cri琀椀cal test cases for priori琀椀za琀椀on requires a deep
understanding of the so昀琀ware's requirements, architecture, and poten琀椀al risks.
In summary, minimiza琀椀on and priori琀椀za琀椀on are integral to e昀케cient and e昀昀ec琀椀ve test
genera琀椀on in so昀琀ware tes琀椀ng. Minimiza琀椀on reduces redundancy in test cases, while
priori琀椀za琀椀on ensures that cri琀椀cal test cases are generated and executed early in the tes琀椀ng
process, resul琀椀ng in higher-quality so昀琀ware delivered within resource constraints.
Regression Testing
Regression tes琀椀ng is a black box tes琀椀ng techniques. It is used to authen琀椀cate a code change
in the so昀琀ware does not impact the exis琀椀ng func琀椀onality of the product. Regression tes琀椀ng
is making sure that the product works 昀椀ne with new func琀椀onality, bug 昀椀xes, or any change in
the exis琀椀ng feature.
Regression tes琀椀ng is a type of so昀琀ware tes琀椀ng. Test cases are re-executed to check the
previous func琀椀onality of the applica琀椀on is working 昀椀ne, and the new changes have not
produced any bugs.
Regression tes琀椀ng can be performed on a new build when there is a signi昀椀cant change in the
original func琀椀onality. It ensures that the code s琀椀ll works even when the changes are
occurring. Regression means Re-test those parts of the applica琀椀on, which are unchanged.
Regression tests are also known as the Veri昀椀ca琀椀on Method. Test cases are o昀琀en
automated. Test cases are required to execute many 琀椀mes and running the same test case
again and again manually, is 琀椀me-consuming and tedious too.
the product. Verify that the bugs 昀椀xed and the newly added features not created any
problem in the previous working version of the So昀琀ware.
The need for regression tes琀椀ng comes when so昀琀ware maintenance includes enhancements,
error correc琀椀ons, op琀椀miza琀椀on, and dele琀椀on of exis琀椀ng features. These modi昀椀ca琀椀ons may
a昀昀ect system func琀椀onality. Regression Tes琀椀ng becomes necessary in this case.
Regression tes琀椀ng can be performed using the following techniques:
1. Re-test All:
Re-Test is one of the approaches to do regression tes琀椀ng. In this approach, all the test case
suits should be re-executed. Here we can de昀椀ne re-test as when a test fails, and we
determine the cause of the failure is a so昀琀ware fault. The fault is reported, we can expect a
new version of the so昀琀ware in which defect 昀椀xed. In this case, we will need to execute the
test again to con昀椀rm that the fault 昀椀xed. This is known as re-tes琀椀ng. Some will refer to this
as con昀椀rma琀椀on tes琀椀ng.
The re-test is very expensive, as it requires enormous 琀椀me and resources.