|
|
Equivalence Partitioning for ADK Agent Test Cases
Author: Venkata Sudhakar
Equivalence partitioning reduces the number of test cases needed by grouping inputs that the agent handles identically into partitions, then testing one representative value from each. ShopMax India uses this technique for its shipping cost calculator and discount engine agents - instead of testing every possible order value, it identifies valid, invalid, and special-case partitions and tests one value per partition, cutting test suite size by 80% while maintaining full logic coverage.
For a shipping cost tool, the partitions might be: prepaid orders (always free shipping), standard orders under Rs 500 (flat fee), standard orders Rs 500-4999 (sliding scale), premium orders Rs 5000+ (free shipping), and invalid negative values (error). Each partition behaves the same for any value within it, so testing one value is sufficient. The partition map is documented as a comment or fixture so future developers understand the coverage rationale.
The example below partitions a shipping cost calculator into five equivalence classes and tests one representative value from each partition using pytest.mark.parametrize.
It gives the following output,
P1: Rs -100 correctly rejected
Rs 2000 prepaid=True: shipping=Rs 0 (prepaid)
Rs 250 prepaid=False: shipping=Rs 99 (standard_low)
Rs 1500 prepaid=False: shipping=Rs 49 (standard_mid)
Rs 7500 prepaid=False: shipping=Rs 0 (free_premium)
5 passed in 0.06s
Document partition boundaries in the tool's docstring using a table so that when business rules change, reviewers immediately see which test cases need updating. Use equivalence partitioning together with boundary value testing - partitioning identifies what to test, boundary testing finds off-by-one bugs at partition edges. Add a partition for each new special case as the business grows (e.g. GST-exempt orders, B2B bulk orders) rather than adding ad-hoc test cases.
|
|