DEV Community

Ambika
Ambika

Posted on

Testing Techniques with examples

  1. Boundary Value Analysis (BVA) Description: Boundary Value Analysis is a testing technique that focuses on the values at the boundaries of input ranges rather than the center. It is based on the observation that errors tend to occur at the boundaries of input values.

Example: Consider a function that accepts an integer input within the range of 1 to 100. The boundary values to test would include:

Valid Boundaries: 1, 100
Invalid Boundaries: 0, 101
Test Cases:

  • Input: 0 (invalid)
  • Input: 1 (valid)
  • Input: 50 (valid)
  • Input: 100 (valid)
  • Input: 101 (invalid)
  • Decision Table Testing Description: Decision Table Testing is a technique used to test complex business logic. It involves creating a table that outlines different combinations of inputs and the corresponding expected outputs. This helps in systematically covering all possible scenarios.

Example: Consider a login feature that has the following conditions:

  • User is Admin or Regular User
  • Password is correct or incorrect

Test Cases:

  1. User Type: Admin, Password Correct: Yes → Expected Result: Access Granted
  2. User Type: Admin, Password Correct: No → Expected Result: Access Denied
  3. User Type: Regular User, Password Correct: Yes → Expected Result: Access Granted
  4. User Type: Regular User, Password Correct: No → Expected Result: Access Denied
  5. Use Case Testing Description: Use Case Testing involves validating the functionality of a system based on real-world scenarios. It focuses on how users interact with the system and ensures that all user requirements are met.

Example: For an online shopping application, a use case could be "Purchase an Item". The use case may include the following steps:

  1. User logs into the account.
  2. User searches for an item.
  3. User adds the item to the cart.
  4. User proceeds to checkout.
  5. User enters shipping information and payment details.
  6. User confirms the order. Test Cases:
  • Verify that the user can log in successfully.
  • Verify that the search function returns the correct items.
  • Verify that the item can be added to the cart.
  • Verify that the checkout process works correctly.
  • LCSAJ Testing (Linear Code Sequence and Jump) Description: LCSAJ Testing is a technique that focuses on the control flow of the program. It involves testing the linear sequences of code and the jumps (like conditional statements) to ensure all paths are covered. It helps in identifying the logic errors in the program.

Example: Consider the following pseudo-code:

plaintext
Copy code

  1. Start
  2. If condition A is true then
  3. Execute Block 1
  4. Else
  5. Execute Block 2
  6. End LCSAJ Analysis:
  • Linear Code Sequences: (1, 2, 3), (1, 2, 5)
  • Jumps: From line 2 to line 3 or line 5 Test Cases:
  1. Test Case 1: Input where condition A is true (this will cover Block 1).
  • Execute Sequence: (1, 2, 3)
  • Test Case 2: Input where condition A is false (this will cover Block 2).

  • Execute Sequence: (1, 2, 5)
    Summary
    Each of these testing techniques serves a unique purpose and is beneficial in different contexts:

  • Boundary Value Analysis helps identify edge cases in input ranges.

  • Decision Table Testing systematically covers complex business logic.

  • Use Case Testing focuses on real-world user scenarios.

  • LCSAJ Testing ensures thorough coverage of code paths and logic flow.

Top comments (0)