Software Testing Module 5 Important Topics PYQs
Software Testing Module 5 Important Topics PYQs
Topics-PYQs
For more notes visit
https://rtpnotes.vercel.app
Purpose: Regression testing ensures that any new changes or fixes made to the software
(such as bug fixes or new features) do not negatively affect the existing functionalities of the
application.
When it's performed: It's done after changes, updates, or defect fixes are applied to the
software.
Focus: It focuses on verifying that the existing features still function correctly after changes.
Scope: The scope is typically broad, as it tests existing functionalities across the entire
system.
Efficiency: May require running a large number of tests to check all aspects of the
software, leading to higher test execution time.
Purpose: OAT is used to test complex functionalities or applications where it's essential to
achieve maximum code coverage with a minimal number of test cases.
When it's performed: It is used when there are a large number of input combinations that
need to be tested.
Focus: It focuses on creating test cases that cover different combinations of parameters
systematically, often focusing on variations that may not be easily covered by traditional
testing methods.
Scope: The scope is more specific and optimized, targeting combinations of inputs that may
have a significant impact on the software’s behavior.
Efficiency: It is highly efficient because it reduces the number of test cases required by
selecting representative combinations of input values. It helps in large test data scenarios
with numerous combinations.
Summary of Differences:
In essence, regression testing ensures stability after changes, while orthogonal array testing is
a strategic approach to efficiently cover complex test cases.
1. Unit Testing
1. A unit test is a type of software testing where you test a small part (unit) of the
software, usually a function or a method, to make sure it works as expected.
2. It’s like checking if one small piece of a puzzle fits properly. For example, you might
write a unit test to check if a function that adds two numbers gives the correct result.
2. Parameterized Unit Testing:
1. Now, parameterized unit testing takes unit testing a step further. Instead of testing
just one fixed set of inputs, you make the test flexible by passing in different inputs
(parameters) to the test.
2. This helps test how your code behaves with various inputs, rather than just one.
3. Example: Imagine a test to check if an “addition” function works correctly. In a regular
unit test, you might check 2 + 3 = 5 . But in a parameterized unit test, you can pass
different values like 4 + 6 , 7 + 8 , and so on, to see if the function handles all of
them correctly.
4. Why is it useful? It saves you time by automatically running the test with multiple
values, making sure your code works in various situations.
Non-Intrusive:
Gray box testing is considered non-intrusive because it doesn’t require direct
changes to the source code or invasive techniques. It typically involves analyzing the
system’s behavior from both the outside and inside, without disrupting the operation of
the software.
Patterns in Software:
In software, "patterns" refer to recurring sequences or behaviors. For example, a
pattern could be how a user fills out a form (e.g., entering a name, followed by an
email, then a phone number) or a sequence of actions taken in an application (like
opening a file, editing it, and saving it).
Test Cases Based on Patterns:
In pattern testing, test cases are designed to follow these common patterns. By doing
this, testers check whether the software handles these predictable scenarios correctly.
Let’s say you’re testing a login form in a web application. The typical pattern for a user might
be:
1. Entering a username.
2. Entering a password.
3. Clicking the “Login” button.
A pattern test case would involve checking if the system correctly handles this series of
actions (inputting a username, password, and submitting the form).
1. Checks Common User Behaviors: It simulates how real users might interact with the
software by following typical patterns. This ensures that the most common use cases are
handled correctly.
2. Finds Bugs in Routine Actions: By testing patterns that people often use, you can find
bugs or issues that might arise during normal usage.
3. Ensures Consistency: It ensures the software behaves consistently when users follow
certain patterns, like filling out forms or navigating through different screens.
Program Testing involves running a program with concrete inputs (like specific values,
e.g., numbers or strings) and checking whether the program behaves as expected with
those inputs. It’s typically used to identify bugs or incorrect behaviors in the program.
Example: Testing a function that adds two numbers by running it with specific inputs like 3
+ 5 , 2 + 4 , etc.
Symbolic execution lies somewhere between program testing and program proving.
Instead of running the program with specific inputs (as in testing), you run it with
symbolic inputs, which represent arbitrary values.
For example, instead of testing a function with 3 + 5 , you would use symbolic values like
x and y and analyze the program's behavior in terms of expressions involving x and y .
This allows you to explore how the program behaves for a wider range of inputs
without actually testing them all.
Symbolic execution builds path conditions—mathematical formulas that describe the
constraints on inputs that must hold true for a particular execution path. These path
conditions help you reason about the behavior of the program.
1. Testing uses concrete inputs to check for real-world bugs. It doesn't guarantee that the
program will work for every possible input.
Example: You test a function with x = 3 and y = 5 , but that doesn't mean it will work
for x = 1000 and y = -500 .
2. Proving guarantees that the program will behave correctly for all possible inputs by
proving its correctness mathematically. This is usually very difficult and time-consuming.
3. Symbolic execution allows you to simulate running the program with all possible inputs by
using symbols instead of concrete values.
1. This gives you a deeper understanding of the program's behavior without having to
manually test every possible combination of inputs, yet without needing a full
mathematical proof of correctness.
2. Midway Point: Symbolic execution bridges the gap between testing and proving
because:
3. It tests multiple inputs simultaneously, covering many scenarios without explicitly
running the program for every input.
4. It doesn't guarantee full correctness as program proving does, but it provides much
broader coverage than traditional program testing.
6. Write the need for grey box testing and list the steps in
grey box methodology.
Gray Box Testing is a mix of two common testing methods: Black Box Testing (focusing only
on what the system does) and White Box Testing (focusing on how the system works
internally). Here’s why it’s needed:
Combines the Benefits of Both Black Box and White Box Testing:
Gray box testing gives testers some understanding of the internal structure of the
system, while also focusing on its external behavior.
This means testers can verify how the system works (like white box testing) and also
check if it meets the user's requirements (like black box testing).
Improves Overall Product Quality
By including insights from both the developers (internal knowledge) and testers
(external behavior), gray box testing helps improve the quality of the product, ensuring
it works well for users and is built efficiently.
Reduces Overhead in Testing Functional and Non-Functional Aspects:
Gray box testing reduces the need for separate black box and white box testing,
streamlining the process.
It ensures that both functional and non-functional aspects of the system are covered in
fewer steps.
Gives Developers Time to Fix Defects:
Testers have some internal knowledge of the system, so they can identify issues more
quickly.
This gives developers enough time to fix the defects before they become bigger
problems.
The program runs normally, but now calculations happen using symbols.
As the program runs, it builds conditions that must be true for the code path taken. These
are called path conditions.
Think of it like:
Instead of saying "If 5 > 0", it says "If x > 0".
And it keeps track of "what must be true" for each way the program could run.
Example
def check(n):
if n > 0:
return "positive"
else:
return "non-positive"
Each branch in the tree happens when the code checks a condition (like an if ).
Ovals represent decision points (like if (n > 0) ).
Rectangles at the bottom are the end points (program outputs).
📖 Tree parts:
Condition at a branch: like "is x > 0?"
Outgoing edges: different possibilities (Yes or No).
Leaf nodes: final result with some specific conditions.
8. Discuss any 2 techniques of grey box testing
Grey box testing is a mix of black box (no code knowledge) and white box (full code
knowledge) testing.
In grey box, the tester knows some internal details of the system but not everything.
1. Matrix Testing
What it is:
In this method, we list and track all the variables in the program.
Why:
To check how variables are used and how they interact with each other.
Example:
Suppose a program has variables like username , password , and email .
Matrix testing ensures we know:
Which functions use these variables
How they are changed
If they are properly validated
2. Regression Testing
What it is:
After changing or fixing something in the code, we check if other parts of the program got
broken accidentally.
Strategies used:
Retest All: Run all old tests again.
Retest Risky Use Cases: Only test the parts most likely to be broken.
Retest Within a Firewall: Only test the affected modules.
Example:
You fixed a bug in the "login" page.
Now, you must check if "login" works and make sure that "signup" or "profile update"
features didn't break because of your change.
4. Pattern Testing
What it is:
Use past defect data (old bugs) to find patterns and predict where bugs are likely to
happen again.
Unlike black box testing:
In grey box, we dig inside the code to understand why the old bugs happened.
Example:
If many bugs were found earlier in the payment module because of wrong calculations, then
during testing, you focus more on that module.
1 int twice(int v) {
2 return 2 * v;
3 }
4
5 void testme(int x, int y) {
6 int z = twice(y);
7 if (z == x) {
8 if (x > y + 10) {
9 ERROR;
10 }
11 }
12 }
13
14 int main() {
15 int x = sym_input();
16 int y = sym_input();
17 testme(x, y);
18 return 0;
19 }
In line no 7
1. This is the first place where the decision takes place
2. It checks if z == x
1. If its true then goes to next if condition at line 8
2. otherwise it exists the program
3. So in the above tree you can see 2 * y == x
1. Here 2 * y is z
In line no 8
if x > y + 10 is true
An example of when this can happen is
x=2
y=1
Save Time: You don't have to write the same test again and again for different inputs.
Better Coverage: You can test with many inputs and catch more bugs.
Easy to Maintain: Changing the test once automatically covers all inputs.
Pex is a tool made for .NET languages that makes parameterized unit testing automatic and
very powerful.
How Pex Helps:
Pex analyzes your Parameterized Unit Test and the code you are testing.
It uses Dynamic Symbolic Execution (smart execution tracking) to:
Watch how your code behaves.
Find important and interesting test cases (especially where bugs might happen).
Pex then automatically creates test inputs that cover:
Different code paths
Edge cases
Potential bugs
If a generated test fails, Pex can sometimes suggest what caused the bug.
Pex ensures you get very high code coverage with only a small number of tests.
It helps in both functional testing (what the program should do) and structural testing
(how the program behaves internally).
When an application has many inputs, each with different possible values,
testing every possible combination becomes impossible because the number of
combinations grows very large.
Example problem:
If you have 4 fields (A, B, C, D), and each field can take 3 different values (1, 2, 3),
Total combinations = 3 × 3 × 3 × 3 = 81 test cases!*
Testing 81 combinations would take too much time and effort**
Simple Example
Without OAT:
Total test cases = 3 × 3 × 3 = 27
With OAT:
Using a simple Orthogonal Array, you may only need around 9 test cases!
Notice:
Each option (Small, Medium, Large, etc.) appears equally and in different combinations.
We still cover all possibilities in an intelligent way.
The main goal is to catch unintended side effects introduced by new code modifications.
When software evolves, even a small change can break previously working features.
Regression testing protects stability and ensures reliability of the system over time.
It helps detect unexpected bugs that may arise indirectly due to changes.
It is a critical activity for maintaining the quality of software during maintenance and
updates.
Suppose an e-commerce app adds a new feature for applying coupon codes at checkout.
In regression testing, apart from testing the new coupon feature, testers will retest:
This ensures that the new code has not broken anything in the existing checkout process.