21BCE0846
21BCE0846
Digital Assignment - I
White-box testing:
White-box testing, also known as clear box testing, glass box testing, or
structural testing, involves examining the internal structure of the software
being tested. Here are some scenarios where white-box testing would be
appropriate:
Explanation:
White-box testing here involves examining the API's internal logic. By reviewing the code
structure, every decision point (such as input validation and error handling) is thoroughly
tested to ensure the endpoint functions correctly.
Practical Example:
Pseudocode Example:
user = fetchUserFromDatabase(userId)
if user is null:
return errorResponse(404, "User not found")
if requestBody.firstName exists:
user.firstName = requestBody.firstName
if requestBody.lastName exists:
user.lastName = requestBody.lastName
if requestBody.email exists:
if not isValidEmail(requestBody.email):
user.email = requestBody.email
if requestBody.age exists:
user.age = requestBody.age
if requestBody.isActive exists:
user.isActive = requestBody.isActive
saveUserToDatabase(user)
Test Cases :
● Partial Update: Only some fields provided should update, leaving others unchanged.
● Invalid Email/Age: Incorrect email or out-of-bound age should trigger 400 error
responses.
5. Code Review and Static Analysis
Scenario: A software company is about to release a new version of its flagship product.
1. Objective
● Identify Code Defects Early: Detect syntax errors, logical flaws, and security
vulnerabilities before runtime.
● Improve Maintainability: Ensure that the code follows best practices and is easy to
modify in the future.
● Enhance Performance & Security: Identify inefficient code segments and security
weaknesses such as memory leaks or SQL injection risks.
2. Testing Approach
A. Code Review
A manual inspection of the source code to find potential issues before execution. This can be
done using:
B. Static Analysis
A tool-based approach that examines source code without executing it. It helps detect:
● Syntax and Logical Errors: Unused variables, unreachable code, improper conditions.
● Security Vulnerabilities: SQL injection risks, buffer overflows, weak cryptographic
implementations.
3. Execution Environment
● Static Analysis Tools: SonarQube, Coverity, Checkstyle, PMD (for Java), Flake8 (for
Python).
● Actionable Fixes: Identified issues are prioritized and resolved before release.
5. Conclusion
White-box testing techniques like code review and static analysis help software companies
ensure the reliability, security, and efficiency of their products before release. By analyzing the
internal structure and logic of the code, these methods prevent defects from reaching
production, ultimately improving software quality.
Blackbox Testing
Black-box testing involves testing the functionality of a software application without examining
its internal code structure. Testers focus on the external behavior of the software and do not
have access to its
Blackbox Testing
1. Objective
● Ensure Stability: Confirm that the new release has not inadvertently affected core
functionalities from previous versions.
● Existing Test Suite: Utilize and update the existing suite of functional test cases that
cover these critical areas.
● New Features Impact: Include test cases that not only re-test the existing
functionalities but also validate the interactions with any newly introduced features.
3. Testing Approach
● Input-Output Analysis:
○ Inputs: Use predefined data sets that represent common, boundary, and error
conditions (e.g., valid and invalid transaction entries).
○ Expected Outputs: Define clear expected outcomes for each input scenario
based on previous system behavior.
● Techniques Applied:
○ Equivalence Partitioning: Group input data into equivalent classes where test
cases are expected to produce similar results.
4. Execution Environment
● Simulated Production: Run the test cases in an environment that closely replicates
the production setting to capture realistic system behavior.
● Outcome Comparison: Compare the actual outputs from the new release against the
expected results.
● Feedback Loop: Provide timely feedback to the development team to address any
identified problems before the release is fully deployed.
6. Conclusion
Using black-box testing for regression testing in this scenario allows testers to effectively
verify that new software updates do not disrupt existing functionality. By focusing on user
behavior and output verification, this approach ensures that the accounting software remains
reliable and user-friendly after each update.
14. Penetration Testing for Security Assessment
1. Objective
● Input Validation: Check for vulnerabilities in user input fields (e.g., search boxes,
contact forms) to prevent injection attacks.
3. Testing Approach
○ Fuzz Testing: Inject unexpected, malformed, or random data to check how the
system responds.
○ Brute Force Attacks: Test password policies by attempting dictionary-based
attacks.
○ Injection Attacks: Try SQL injection and cross-site scripting (XSS) to determine
if user input is properly sanitized.
4. Execution Environment
● Ethical Hacking Tools: Use tools like Burp Suite, OWASP ZAP, Metasploit, or Nikto to
conduct automated and manual security testing.
6. Conclusion
Black-box penetration testing helps e-commerce platforms identify and fix security
vulnerabilities before attackers can exploit them. By mimicking real-world cyber-attacks, this
approach ensures robust security, protecting user data, transactions, and business reputation.
Mutation Testing
Mutation testing is a technique used to evaluate the effectiveness of existing
test cases by introducing small changes, or mutations, into the source code
and checking if the tests can detect these changes. Here are some scenarios
for mutation testing:
1. Objective
● Evaluate Test Suite Strength: Ensure that existing unit test cases are robust enough
to catch errors in arithmetic operations.
● Identify Weak Test Cases: Detect gaps in test coverage where incorrect calculations
might go unnoticed.
Mutants are created by modifying arithmetic operations in the source code. Examples include:
x = (a + b) * c; x = (a + b) + c; Multiplication changed to
addition
3. Testing Approach
● Generate Mutants: Use mutation testing tools (such as PIT for Java, MutPy for Python)
to introduce small changes in the arithmetic operations.
● Run Test Cases: Execute the existing test cases against the mutated versions of the
code.
● Analyze Results:
○ Killed Mutants: If a test case fails due to the mutation, it means the test
successfully detected the issue.
○ Survived Mutants: If a test case passes despite the mutation, it indicates that
the test suite is weak and needs improvement.
4. Execution Environment
● Automation Tools: Use mutation testing frameworks (e.g., PIT for Java, MutPy for
Python, Stryker for JavaScript) to automate the process.
● Code Coverage Analysis: Ensure that all arithmetic operations are tested by analyzing
code coverage reports.
● Mutation Score Calculation: Determine the effectiveness of test cases using the
formula:
Mutation Score=(Killed MutantsTotal Mutants)×100\text{Mutation Score} =
\left(\frac{\text{Killed Mutants}}{\text{Total Mutants}}\right) \times 100
● Improve Test Cases: If the mutation score is low, add new test cases to improve
detection accuracy.
6. Conclusion
Mutation testing ensures that an application’s test suite is capable of identifying faults in
arithmetic operations. By systematically altering mathematical expressions, it helps
developers strengthen their test cases, ultimately leading to more reliable and bug-free
software.