Decision Table Testing
Introduction
Many APIs implement business rules where the response depends on more than one input condition. A simple validation rule may check whether a field is required or whether a number is within a range, but real production APIs often make decisions based on combinations of conditions. Those combinations can quickly become difficult to test by memory or guesswork.
For example, a banking API may approve a loan based on age, salary, credit score, employment status, and existing debt. An e-commerce API may apply a discount based on membership status, coupon validity, purchase amount, product category, and region. A login API may grant access based on username validity, password correctness, account status, MFA status, and lockout rules.
Testing every possible combination manually is difficult. It is easy to test the happy path and a few obvious failures while missing important mixed conditions. Decision Table Testing solves this problem by representing conditions and expected actions in a structured table.
Decision Table Testing is a black-box test design technique that systematically tests meaningful combinations of conditions and the actions that should result from those combinations. It is especially useful for API testing because APIs commonly enforce business rules, eligibility rules, pricing logic, authorization decisions, and workflow transitions.
What Is Decision Table Testing?
Decision Table Testing is a black-box testing technique that represents combinations of input conditions and expected outcomes in a tabular format. Each column in the table usually represents one rule or one test scenario, while rows represent conditions and actions.
In simple terms, Decision Table Testing verifies API behavior by testing different combinations of input conditions and their expected results. Instead of writing scattered test cases, the tester first identifies the decision logic and then maps it into a table.
This technique is useful when the API response depends on multiple conditions. If a single condition changes the outcome, simple positive and negative testing may be enough. But if several conditions interact, a decision table gives the tester a clear way to cover the logic.
A decision table also improves communication. Developers, testers, business analysts, product owners, and interviewers can look at the table and understand which combinations are covered and what outcome is expected.
Why Decision Table Testing Is Important
Decision Table Testing is important because complex business rules often contain hidden combinations. A tester may remember to test valid username and correct password, but forget the case where the password is correct and the account is locked. A discount API may work for premium members and high purchase amounts, but fail when a coupon is expired or a product category is excluded.
The technique helps validate complex business rules. When conditions are listed explicitly, gaps become visible. If a rule says that premium users get one discount and coupon users get another, the table can show what should happen when both conditions are true.
Decision tables also improve test coverage. They force the tester to consider condition combinations instead of isolated inputs. This is important because many API defects occur when individually valid inputs are combined in a special way.
They reduce missed scenarios. Without a table, test cases are often written from memory, and memory is unreliable. With a table, each combination has a visible place. The team can review it and decide whether it is valid, invalid, impossible, redundant, or high priority.
Decision Table Testing also detects logical defects. These include wrong priority rules, missing else conditions, incorrect rejection logic, inconsistent approval rules, duplicate actions, and behavior that contradicts business requirements.
Decision Table Workflow
A practical decision table workflow begins by identifying the business decision being tested. The decision should be clear. For example, approve loan, apply discount, allow login, create order, verify OTP, calculate shipping, or authorize payment.
Next, identify the conditions that influence that decision. Conditions are the inputs or states that affect the outcome. In a loan API, conditions may include age eligibility, salary threshold, credit score, and employment status. In a login API, conditions may include valid username, correct password, active account, and MFA requirement.
After conditions are identified, define the possible values for each condition. Many examples use Yes and No, but real APIs may use more than two values. Account status may be Active, Locked, Disabled, or Pending. Payment status may be Success, Failed, Pending, or Reversed. Membership level may be None, Silver, Gold, or Platinum.
Then identify the actions or expected outcomes. Actions may include login success, invalid password, account locked, loan approved, loan rejected, order created, payment failed, discount applied, or authorization denied.
Finally, create the decision table and generate test cases from it. Each meaningful column becomes one API test scenario. The test should send the required inputs, execute the API, and verify the expected status code, response body, business result, database update, and side effects.
Components of a Decision Table
A decision table typically contains conditions, condition values, actions, and rules. Conditions describe the factors that influence behavior. Condition values show whether each condition is true, false, or has a specific value. Actions describe what the API should do. Rules are the combinations that become test scenarios.
For a simple table, conditions may be shown as Yes or No rows. For example, Username valid? Yes or No. Password correct? Yes or No. Each column combines these values and maps to an expected action.
Actions are equally important. A weak decision table lists conditions but does not clearly define the expected result. A good decision table states the action precisely, such as return 200 with token, return 401 invalid password, return 423 account locked, or return 403 access denied.
Rules represent test scenarios. If there are two binary conditions, there are four possible combinations. If there are three binary conditions, there are eight combinations. If there are four binary conditions, there are sixteen combinations. This grows quickly, so testers must understand which combinations are meaningful and which can be simplified.
Structure of a Decision Table
A common decision table structure places conditions on the left and rule columns on the right. Each rule column contains the condition values for one scenario. Below the condition rows, action rows show the expected outcome for that rule.
For example, a table may contain Condition A and Condition B. Rule 1 may have both conditions Yes, Rule 2 may have A Yes and B No, Rule 3 may have A No and B Yes, and Rule 4 may have both No. Each rule then maps to Action 1, Action 2, Action 3, or Action 4.
In API testing, the table can be converted into test data. Each column becomes one request payload or one data row in an automated test. This makes decision tables useful not only for manual design but also for data-driven automation.
Example: Login API
Consider a login API where the basic conditions are username valid and password correct. The API endpoint is POST /login. The possible combinations are valid username with correct password, valid username with incorrect password, invalid username with correct password, and invalid username with incorrect password.
The expected outcomes may be login success, invalid password, invalid username, and login failed. This produces four test cases. A tester who only tests successful login and invalid password misses the invalid username combinations.
In a real login API, the decision table may be larger. Conditions may include account locked, account disabled, password expired, MFA required, too many attempts, and IP blocked. The table helps clarify which error should take priority when multiple conditions are true.
Example: Employee Bonus API
An employee bonus API may award a bonus only when experience is at least five years and performance rating is Excellent. The conditions are Experience >= 5 years and Performance = Excellent. The action is Bonus Yes or Bonus No.
The table has four combinations. If both conditions are Yes, bonus is awarded. If experience is Yes but performance is No, no bonus is awarded. If experience is No but performance is Yes, no bonus is awarded. If both are No, no bonus is awarded.
This example looks simple, but it shows the value of the technique. If the API accidentally awards bonus for excellent performance without experience, the table exposes that expected result should be No.
Example: Loan Approval API
A loan approval API may require age >= 21, salary >= 50000, and credit score >= 700. These are three binary conditions, so the full table has eight possible combinations. Only the combination where all three conditions are Yes may result in approval. All other combinations may result in rejection.
The eight scenarios are important because each rejected combination proves a different rule. A user with good salary and credit score but underage should be rejected. A user with valid age and salary but low credit score should be rejected. A user with valid age and credit score but low salary should be rejected.
If the API approves any case where one required condition is missing, the business rule is broken. Decision Table Testing makes those missing-condition defects visible.
Example: Discount API
An e-commerce discount API may apply discounts based on premium membership and purchase amount greater than 500. The decision table may say premium member with amount above 500 gets 20 percent, premium member with amount not above 500 gets 10 percent, non-premium customer with amount above 500 gets 10 percent, and non-premium customer below or equal to 500 gets no discount.
This example shows that actions do not always have only pass or fail results. Different combinations may produce different valid outcomes. API tests should verify the exact discount percentage, not only whether the response succeeds.
Discount APIs often have additional conditions such as coupon validity, product exclusions, region restrictions, first-time customer rules, and sale period. A decision table helps avoid incorrect discount stacking or missing exclusions.
Applying Decision Table Testing in APIs
Decision Table Testing is useful for login APIs, authentication, authorization, loan approval, payment validation, discount calculation, order processing, shipping rules, tax calculation, insurance policies, subscription plans, workflow approvals, and eligibility checks.
Authentication APIs often depend on credentials, account state, token expiry, MFA status, lockout status, and risk checks. Authorization APIs depend on user role, permission, resource ownership, organization, and feature flag. Payment APIs depend on amount, method, gateway response, fraud result, currency, and transaction status.
Order APIs may depend on product availability, payment success, shipping address validity, coupon validity, and inventory reservation. Tax APIs may depend on country, state, product category, exemption status, and customer type.
Whenever the question is "what should happen when these conditions are combined?", a decision table is usually a strong test design option.
Example: Order API
Consider an order API with two conditions: product available and payment successful. If both are Yes, the order should be created. If stock is available but payment fails, the result should be payment failed. If stock is unavailable but payment succeeds, the result should be out of stock and the payment should not be captured incorrectly. If both fail, the order should fail cleanly.
This scenario shows why API tests must validate side effects. It is not enough to check the response text. If stock is unavailable and payment succeeds, the system should not leave a charged payment without an order unless there is a defined compensation flow.
Decision Table Testing helps define expected behavior for each combination before automation is written. That prevents the automation from simply copying whatever the system currently does.
Example: OTP Verification
An OTP verification API may depend on whether the OTP is valid and whether it is expired. A valid non-expired OTP should succeed. A valid but expired OTP should return OTP expired. An invalid non-expired OTP should return invalid OTP. An invalid expired OTP may also return invalid OTP depending on security rules.
This example highlights action priority. If an OTP is both invalid and expired, which message should the API return? Some systems prefer invalid OTP to avoid revealing expiry information. Others return expired if the OTP record exists. The decision table forces the team to define that behavior.
Decision Table Testing in API Testing
QA engineers should verify every business rule, every meaningful condition combination, expected actions, status codes, error messages, response bodies, database updates, authorization rules, validation logic, and side effects.
For a success scenario, the API should return the expected success status, correct response body, and correct persisted state. For a failure scenario, the API should return a controlled error and avoid unintended updates.
Decision table scenarios should also verify priority where multiple failures can occur. For example, if a user is disabled and the password is wrong, the API may be required to return account disabled rather than invalid password. Without a decision table, these priority rules are often missed.
Example Test Scenarios
For a login API, conditions may be username valid and password correct. Test all four combinations and verify success, invalid password, invalid username, and login failure behavior.
For a discount API, conditions may be premium member and purchase amount greater than the threshold. Test all four combinations and verify exact discount amount or percentage.
For a loan API, conditions may be age, salary, and credit score. Test all eight combinations, or test all meaningful combinations if business rules make some cases impossible.
For an order API, conditions may be stock available and payment successful. Test all four combinations and verify order creation, payment failure, out-of-stock behavior, and clean failure behavior.
Validation Checklist
A decision table validation checklist should include every rule, every meaningful condition combination, status code, response body, error message, database changes, business logic, audit logs, downstream events, and side effects.
For APIs that update data, verify the database state after each rule. If an order is rejected, no order should be created unless the system stores rejected attempts by design. If payment fails, inventory should not be reduced. If authorization fails, protected data should not be returned.
For APIs that publish events or messages, verify that events are produced only when expected. A failure response should not trigger a success event. A discount calculation should not update customer rewards unless the rule says so.
REST Assured Example
In REST Assured, each decision table rule can become one automated test or one data row in a parameterized test. For example, a login rule with valid username and wrong password sends a request and expects status 401.
The same endpoint can be executed with the remaining combinations. A data-driven approach is often cleaner because the table of inputs and expected outcomes can be represented as test data.
Assertions should check status code, response body, error code, and any important side effects. For login, this may include verifying that no access token is returned for failed login and that failed attempt counters behave as expected.
Postman Example
In Postman, testers can create one request for each decision table rule or use a collection runner with a data file. Each data row can contain condition values and expected results. Test scripts can assert status code, response message, and response fields.
Postman is useful for early decision table validation because teams can quickly run combinations and review API behavior. Once rules are stable, the same scenarios can be implemented in a long-term automation framework.
Karate Example
Karate is well suited for decision table testing because scenario outlines can hold input combinations and expected outcomes in readable form. Each row in the examples table can represent one decision table rule.
For example, a login feature can list username validity, password correctness, account status, expected status code, and expected message. This keeps business rules visible while still producing executable API tests.
Real-World Examples
In banking, loan approval may depend on age, salary, credit score, employment status, existing debt, and KYC status. A decision table can define which combinations approve, reject, or require manual review.
In healthcare, appointment approval may depend on doctor availability, patient eligibility, insurance coverage, referral requirement, and appointment type. Different combinations may allow booking, reject booking, or require pre-authorization.
In e-commerce, discount calculation may depend on membership, coupon validity, purchase amount, product category, region, and sale period. A decision table can prevent incorrect discounts and discount stacking defects.
In insurance, premium calculation may depend on age, health condition, policy type, coverage amount, smoking status, and claim history. Decision tables help verify pricing and eligibility logic.
Decision Table vs Equivalence Partitioning
Decision Table Testing and Equivalence Partitioning solve different problems. Decision Table Testing tests combinations of conditions. Equivalence Partitioning tests representative values from input groups.
EP is useful when validating a field range such as age below 18, age 18 to 60, and age above 60. Decision Table Testing is useful when age interacts with salary, credit score, account status, or other conditions.
In API testing, both techniques often work together. EP can identify meaningful input groups for each condition, and decision tables can combine those groups to test business logic.
Decision Table vs Boundary Value Analysis
Decision Table Testing focuses on combinations of multiple conditions. Boundary Value Analysis focuses on values at input boundaries. BVA is ideal for limits such as minimum age, maximum quantity, password length, page size, date range, and file size.
Decision tables are ideal when outcomes depend on condition combinations. For example, a value at the boundary may be technically valid, but the final decision may still depend on membership, account status, or approval level.
A strong API test strategy may use BVA for each condition's edge values and decision tables for the business combinations. This gives both field-level and rule-level coverage.
Handling Many Conditions
Decision tables can grow quickly. Three binary conditions create eight combinations. Four create sixteen. Five create thirty-two. If each condition has more than two values, the number grows even faster.
When the table becomes large, testers should identify impossible combinations, redundant combinations, and high-risk combinations. Some combinations cannot occur in real business flow. Others may lead to the same action and can be collapsed if coverage remains clear.
However, reduction should be done carefully. Do not remove a scenario only because it looks similar. Remove it only when the business rule truly makes it redundant or impossible. Risk-based judgment is important.
Business Rule Priority
Many APIs have rule priority. For example, if an account is disabled, the API may reject the login before checking password correctness. If a coupon is expired and also not applicable to the product, the API must decide which error message to return.
Decision tables help capture these priorities. Each combination can show the expected action, and the team can review whether the action is correct. This prevents inconsistent behavior and confusing errors.
Rule priority is especially important for security APIs. Returning too much detail may reveal sensitive information. A decision table helps define whether the API should return a generic failure or a specific message.
Best Practices
Identify all business conditions before creating test cases. Conditions should come from requirements, user stories, API documentation, business rules, product discussions, and observed workflows.
Define all possible actions clearly. Avoid vague outcomes such as "works" or "fails." Use specific expected results such as order created, payment failed, invalid password, account locked, discount 20 percent, or loan rejected.
Create a complete decision table first, then generate tests from it. This makes coverage visible before automation work begins.
Remove impossible or invalid combinations where appropriate, but document why they were removed. This keeps the table readable without hiding test gaps.
Test every valid rule. If a combination can occur in production and affects the outcome, it should have test coverage.
Automate decision table scenarios using data-driven tests where possible. This keeps the test suite maintainable as combinations change.
Validate both success and failure outcomes, including response body, status code, data changes, and side effects.
Common Mistakes
A common mistake is missing condition combinations. Testers may cover the happy path and a few errors but miss mixed cases where one condition is true and another is false.
Another mistake is ignoring business rules. Decision tables should reflect actual business logic, not tester assumptions. If the expected outcome is unclear, clarify it before writing automation.
Testing only positive scenarios is also a problem. Complex logic often fails in negative or mixed combinations. Include invalid, rejected, blocked, expired, unauthorized, and unavailable cases.
Creating duplicate rules can make the test suite larger than necessary. If two columns truly represent the same behavior and no business distinction exists, they may be merged. But do this carefully.
Overlooking impossible combinations is another issue. Some combinations cannot occur because earlier workflow steps prevent them. Keeping too many impossible combinations can make the table noisy. Mark them clearly or exclude them with explanation.
Advantages
Decision Table Testing is excellent for complex business logic. It provides a structured way to test APIs whose behavior depends on multiple conditions.
It provides high decision coverage. Because combinations are visible, teams can identify missing scenarios and verify every meaningful rule.
It is easy to understand. A table is often clearer than a long list of test cases. Stakeholders can review it and confirm whether business behavior is correct.
It reduces missed scenarios and improves test completeness. This is especially valuable for critical APIs such as authentication, payments, discounts, loans, insurance, healthcare eligibility, and order processing.
It is also easy to automate when converted into data-driven tests. Each rule can become one row of test data with input values and expected outcomes.
Limitations
Decision tables can become large when there are many conditions. If every condition has multiple values, the number of combinations may become difficult to manage.
The technique requires clear business rules. If requirements are vague, the decision table may expose gaps, but it cannot decide the expected behavior by itself.
Decision Table Testing also does not replace input validation techniques. It should be combined with Equivalence Partitioning, Boundary Value Analysis, contract testing, negative testing, and exploratory testing.
Another limitation is that not every combination deserves the same priority. Testers still need judgment to choose which combinations are mandatory, which are redundant, and which are low risk.
Interview Questions
A common interview question is: what is Decision Table Testing? A strong answer is that Decision Table Testing is a black-box testing technique that validates API behavior by testing combinations of input conditions and their expected outcomes.
Another question is: why is Decision Table Testing important? It ensures that meaningful business rule combinations are tested and reduces the risk of missing logical defects.
If asked when to use Decision Table Testing, explain that it is useful when API behavior depends on multiple input conditions or business rules, such as authentication, discounts, approvals, pricing, payment validation, or order processing.
If asked how many combinations exist for three Yes or No conditions, explain that each binary condition has two possible values, so the total is 2 to the power of 3, which equals 8.
If asked about Decision Table Testing versus Boundary Value Analysis, explain that Decision Table Testing focuses on combinations of business conditions, while Boundary Value Analysis focuses on values at input boundaries.
Interview-Ready Explanation
Decision Table Testing in API Testing is a black-box test design technique used to validate APIs whose behavior depends on multiple business conditions. It represents different combinations of input conditions and their expected actions in a table, with each column representing one unique test scenario or rule.
This technique is useful for APIs involving complex business logic such as login authentication, loan approvals, discount calculations, payment validation, insurance eligibility, authorization, and order processing. QA engineers identify the relevant conditions, define the possible values, map expected actions, execute each meaningful rule, and verify status codes, response bodies, database changes, and side effects.
Decision Table Testing improves test coverage, reduces missed scenarios, and makes business rules easier to review. It is especially valuable when positive and negative outcomes depend on combinations rather than a single input field.
Key Takeaway
Decision Table Testing helps API testers handle complex business logic in a structured way. Instead of guessing combinations, the tester lists conditions, maps actions, creates rules, and turns those rules into test scenarios.
For practical API testing, use decision tables when multiple conditions control the outcome. Verify not only status codes but also response body, error message, database state, audit logs, authorization behavior, and side effects. When combined with Equivalence Partitioning and Boundary Value Analysis, Decision Table Testing gives strong coverage for both input validation and business rule logic.