Lesson 2_ Test Case Design
Lesson 2_ Test Case Design
Definition:
Requirements are detailed specifications that outline what the software
must accomplish. They serve as a foundation for both the development and
testing processes.
Types of Requirements:
1. Functional Requirements:
○ Define specific behaviors or functionalities of the software.
○ Examples:
■ User authentication (login/logout processes).
■ Data entry and validation (input forms).
■ Business logic (calculations, workflows).
2. Non-Functional Requirements:
○ Specify criteria that judge the operation of a system rather than
specific behaviors.
Summary
Understanding the distinction between functional and non-functional
requirements is crucial for effective test case design. Functional
requirements guide the creation of test cases that validate specific features,
while non-functional requirements ensure the software meets quality
standards in performance, usability, and reliability. By focusing on these
aspects, testers can create comprehensive test cases that cover all
necessary scenarios, contributing to a robust and reliable software product.
1. Actors:
○ Definition: Individuals or systems that interact with the
application.
○ Types:
■ Primary Actor: The main user who initiates the
interaction (e.g., a customer placing an order).
● Actors:
○ Primary Actor: Customer
○ Secondary Actor: Payment Gateway
● Preconditions:
○ Customers must be logged into their account.
○ The selected product must be available.
● Steps:
○ Customers browse products.
By developing detailed use cases, teams can create more effective test
cases, ensuring thorough coverage of user interactions within the
application.
● Purpose:
The Traceability Matrix serves as a tool to map requirements to their
corresponding test cases, ensuring complete coverage and
facilitating tracking of requirements through development and testing.
● Structure:
Typically structured as a table, a Traceability Matrix includes the following
components:
●
Requireme Requirement Test Test Case Stat
nt ID Description Case ID Description us
1. Verification of Coverage:
○ Ensures that every requirement has a corresponding test case,
confirming that all aspects of the application are being tested.
2. Impact Analysis:
○ When requirements change, the matrix helps identify which test
cases need to be updated, ensuring that changes do not lead to
untested areas.
3. Improved Communication:
○ Provides a clear reference for stakeholders (developers,
testers, business analysts) to understand which requirements
are being addressed in testing.
4. Audit Trail:
○ Creates a historical record of requirements and test cases,
useful for future projects and compliance needs.
● Regular Updates:
○ Keep the matrix updated as requirements evolve or new test
cases are created.
● Clear Documentation:
○ Ensure that each entry in the matrix is clear and unambiguous
to avoid misunderstandings.
● Collaboration:
○ Involve all stakeholders in the traceability process to ensure
comprehensive coverage and clarity.
● Automation Tools:
○ Utilize test management tools that can automatically generate
and maintain traceability matrices to streamline the process.
1. Knowledge of Code:
○ Testers must understand the application’s code and logic to
create effective tests.
2. Testing Techniques:
○ Common techniques include:
■ Control Flow Testing: Analyzes the flow of control
through the code.
■ Data Flow Testing: Focuses on the flow of data within
the application and how data variables are defined and
used.
■ Branch Testing: Ensures that each branch (decision
point) in the code is executed at least once.
3. Test Coverage:
○ Aims for high coverage metrics, such as statement coverage,
branch coverage, and path coverage, to ensure that all parts of
the code are tested.
1. Thoroughness:
○ Enables comprehensive testing of all internal paths and
conditions.
2. Early Bug Detection:
○ Bugs can be identified early in the development cycle, reducing
costs associated with fixing issues later.
3. Optimization Opportunities:
○ Helps in identifying areas of code that can be optimized for
performance.
Conclusion
White box testing is a powerful technique that provides deep insights into
the application’s internal workings. By leveraging knowledge of the code,
testers can create comprehensive test cases that ensure the reliability and
performance of the software, making it an essential part of the overall
testing strategy.
Key Concepts
1. Thorough Testing:
○ Ensures all logical paths in the code are tested, leading to
comprehensive coverage.
2. Error Detection:
○ Helps identify errors related to control flow, such as infinite
loops or unreachable code.
Conclusion
Basis path testing is a valuable technique in white box testing that ensures
thorough evaluation of an application's logic by covering all possible
execution paths. By using control flow graphs and calculating cyclomatic
complexity, testers can create a robust suite of test cases that enhance
software quality and reliability.
Cyclomatic Complexity
Definition:
Cyclomatic complexity is a software metric used to quantify the complexity
of a program's control flow. It helps determine the number of linearly
independent paths through the source code, providing insights into the
code's testability and maintainability.
M=E−N+2PM = E - N + 2PM=E−N+2P
Where:
● M = Cyclomatic complexity
● E = Number of edges in the flow graph
● N = Number of nodes in the flow graph
● P= Number of connected components (usually 1 for a single
program)
Example Calculation
Example 1: Simple Control Flow Graph
1. Objective Metric:
○ Provides a clear, quantitative measure of complexity, making it
easier to assess code quality objectively.
2. Improves Test Coverage:
1. Limited Context:
○ While it measures control flow complexity, it does not account
for other factors affecting code quality, such as code readability
or design patterns.
2. Misleading in Some Cases:
○ High cyclomatic complexity does not always indicate poor
quality; it may simply reflect the inherent complexity of the
business logic.
3. Not Comprehensive:
○ Does not consider non-functional requirements, such as
performance or security, which are also critical for overall
software quality.
4. Encourages Quantity over Quality:
○ Developers may focus on reducing cyclomatic complexity at the
expense of implementing necessary features or logic, leading to
oversimplification.
5. Requires Experience:
○ Interpreting cyclomatic complexity results effectively requires
experience; inexperienced developers may misinterpret the
implications.
1. Equivalence Partitioning:
○ Divides input data into valid and invalid partitions to minimize
the number of test cases while ensuring adequate coverage.
○ Example: For a field accepting values 1-100, create partitions
like:
■ Valid: 1-100
■ Invalid: <1, >100
2. Boundary Value Analysis (BVA):
○ Focuses on testing at the boundaries of input ranges.
○ Example: If the valid range is 1-100, test cases would include 0,
1, 100, and 101.
3. Decision Table Testing:
○ Uses a table to represent combinations of inputs and
corresponding expected outputs, ensuring all scenarios are
covered.
1. User Perspective:
○ Reflects real-world usage and user experiences, ensuring the
application meets user needs.
2. Identifies Missing Functionality:
○ Can uncover discrepancies between requirements and actual
software behavior.
3. No Need for Technical Skills:
○ Testers do not need programming knowledge, allowing
non-technical stakeholders to participate in testing.
1. Limited Coverage:
○ Cannot guarantee all possible scenarios are tested, especially
edge cases, since it does not examine internal paths.
2. Difficult to Create Test Cases:
○ Crafting effective test cases can be challenging without
knowledge of the code logic.
3. Debugging Complexity:
○ If defects are found, diagnosing the cause can be difficult since
the internal workings are not visible to the tester.
Conclusion
Black box testing is a vital component of the software testing life cycle,
focusing on the application’s functionality from the end-user’s perspective.
By employing various techniques and emphasizing user requirements, it
ensures that the software meets its intended purpose, contributing to a
high-quality user experience.