CHAPTER 2 Software Testig
CHAPTER 2 Software Testig
Test Strategy:
Test strategy is a comprehensive plan outlining the approach, scope,
resources, and schedule for testing a software application. Its purpose is to
provide guidance on how testing will be conducted to ensure that the software
meets specified quality standards.
Example:
Test Case ID: TC001
Test Case Description: Verify login functionality.
Preconditions: User credentials are valid.
Test Steps:
1. Open the application.
2. Enter valid username and password.
3. Click the "Login" button.
Expected Result: User should be successfully logged in.
Testability:
Testability is the degree to which a system or application facilitates testing. It
involves designing software in a way that makes it easy to create and execute
test cases.
Characteristics of Testability:
- Observability: The ability to observe and measure the system's internal
state and outputs during testing. It involves having proper logging and
monitoring mechanisms.
- Controllability: The degree to which testers can control and manipulate the
system during testing. It includes features like input control and test
environment setup.
Details on Controllability:
Controllability focuses on the tester's ability to control and manipulate the
system during testing. This characteristic is essential for creating diverse test
scenarios and ensuring that the system behaves as expected under different
conditions. Controllability includes features such as input control, test
environment configuration, and the ability to simulate specific conditions for
testing.
5. With the help of a diagram and example, describe white box testing. Also,
state its advantages and disadvantages:
Diagram:
+------------------+
| Application Code |
+------------------+
|
Example:
Consider a function that calculates the sum of two numbers. A white-box test
would involve analyzing the code and creating test cases to ensure all code
paths are covered.
python
def add_numbers(a, b):
if a > 0 and b > 0:
return a + b
elif a < 0 and b < 0:
return a - b
else:
return 0
Advantages:
- Thorough Coverage: It ensures comprehensive coverage of the code paths.
- Early Bug Detection: Can detect issues at the early stages of development.
Disadvantages:
Diagram:
+------------------+
| Application |
| Code |
+------------------+
|
V
+------------+
| Black Box |
| Testing |
+------------+
Example:
html
<!-- Web Application Login Form -->
<form>
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button type="submit">Login</button>
</form>
7. How to design a test case in MS-Excel? Design test cases for mobile and
web applications:
Example:
Consider a simple program with conditional statements:
python
def calculate_discount(price, quantity):
total_amount = price * quantity
Paths:
1. Path 1: Total amount > 1000 (True)
2. Path 2: Total amount > 1000 (False)
Loop Testing:
Loop testing is a testing technique that focuses on testing the functionality of
loops within a program. It ensures that loops execute the correct number of
times, handle boundary conditions, and terminate appropriately.
Example:
Consider a program with a 'for' loop to calculate the sum of numbers:
python
def calculate_sum(numbers):
total = 0
for num in numbers:
total += num
Loop Testing:
- Test with an empty list to ensure the loop handles zero iterations.
- Test with a single element in the list.
- Test with multiple elements in the list.
12. Differentiate between white box testing and black box testing:
Components:
1. Nodes: Represent the points in the program where data is defined or used.
2. Edges: Represent the flow of data between nodes.
Example:
Consider a program with variables A, B, and C:
python
def calculate_sum(a, b):
c=a+b
Data Flow:
- A is defined as input.
- B is defined as input.
- C is defined as output.
14. With the help of an example, describe BVA and EP? Also, compare them:
Example:
For a range of acceptable values (10 to 50), test cases would include 9, 10, 11,
49, 50, and 51.
Example:
Comparison:
- BVA: Tests specific values at the edges or boundaries.
- EP: Tests representative values from different partitions.
- Overlap: Some overlap between BVA and EP is possible.
- Focus: BVA is more focused on edge cases, while EP considers a broader
range of values.
Cyclomatic Complexity:
Cyclomatic complexity is a software metric used to measure the complexity of
a program by counting the number of linearly independent paths through its
source code.
Example:
For a program with three decision points, the formula is:
\[ M = E - N + 2P \]
Where:
- \( M \) is the Cyclomatic Complexity.
- \( E \) is the number of edges.
- \( N \) is the number of nodes.
- \( P \) is the number of connected components.
Graph Matrix:
Example:
Consider a simple program with decision points and control flow:
if (condition1) {
// Code Block 1
} else {
// Code Block 2
}
while (condition2) {
// Code Block 3
}
Graph Matrix:
123
1010
2101
3010
Comparison:
- Cyclomatic Complexity: Quantifies the complexity based on graph analysis.
- Graph Matrix: Visualizes the program's control or data flow to calculate
complexity.