Modern QA2026Equivalence Partitioning via AI — tiles
Log inJoin
20 / 87 · 02 AI-Augmented Test Design · Boundary-Value Analysis and Equivalence Partitioning via AI← prev⊞ allnext →☰ Read as one page

4.3Equivalence Partitioning via AI

The Concept

Equivalence partitioning divides the input space into classes where all values in a class are expected to behave the same way. You test one representative value per class instead of every possible value.

The Prompt Pattern

For the following API endpoint, identify equivalence classes for each input
parameter and generate one representative test per class:

POST /api/orders
{
  "product_id": "string (UUID format)",
  "quantity": "integer (1-100)",
  "shipping_method": "enum: standard | express | overnight",
  "coupon_code": "string (optional, alphanumeric, 8 chars)"
}

For each parameter, identify:
1. Valid equivalence classes
2. Invalid equivalence classes
3. One representative value per class

Expected Output

The LLM should produce partitions like:

product_id:

  • Valid class 1: existing UUID ("550e8400-e29b-41d4-a716-446655440000")
  • Invalid class 1: non-existent UUID ("00000000-0000-0000-0000-000000000000")
  • Invalid class 2: not a UUID ("not-a-uuid")
  • Invalid class 3: empty string ("")
  • Invalid class 4: null

quantity:

  • Valid class 1: minimum (1)
  • Valid class 2: mid-range (50)
  • Valid class 3: maximum (100)
  • Invalid class 1: zero (0)
  • Invalid class 2: negative (-5)
  • Invalid class 3: above max (101)
  • Invalid class 4: non-integer (2.5)
  • Invalid class 5: non-numeric ("ten")

shipping_method:

  • Valid class 1: "standard"
  • Valid class 2: "express"
  • Valid class 3: "overnight"
  • Invalid class 1: non-enum value ("drone")
  • Invalid class 2: empty string ("")
  • Invalid class 3: case variant ("Standard")

coupon_code:

  • Valid class 1: valid code ("SAVE20AB")
  • Valid class 2: absent/omitted (optional field)
  • Invalid class 1: too short ("SAVE20")
  • Invalid class 2: too long ("SAVE20ABC")
  • Invalid class 3: non-alphanumeric ("SAVE-20!")
  • Invalid class 4: lowercase ("save20ab")

Converting EP to Parametrized Tests

class TestOrderCreationPartitions:
    """Equivalence partition tests for POST /api/orders."""

    @pytest.mark.parametrize("quantity,expected_status", [
        (1, 201),       # Valid: minimum
        (50, 201),      # Valid: mid-range
        (100, 201),     # Valid: maximum
        (0, 400),       # Invalid: zero
        (-5, 400),      # Invalid: negative
        (101, 400),     # Invalid: above max
    ])
    def test_quantity_partitions(self, client, auth, valid_product, quantity, expected_status):
        response = client.post("/api/orders", json={
            "product_id": str(valid_product.id),
            "quantity": quantity,
            "shipping_method": "standard",
            "idempotency_key": str(uuid4()),
        }, headers=auth)
        assert response.status_code == expected_status

    @pytest.mark.parametrize("method,expected_status", [
        ("standard", 201),
        ("express", 201),
        ("overnight", 201),
        ("drone", 400),
        ("", 400),
        ("Standard", 400),   # Case sensitivity check
    ])
    def test_shipping_method_partitions(self, client, auth, valid_product, method, expected_status):
        response = client.post("/api/orders", json={
            "product_id": str(valid_product.id),
            "quantity": 1,
            "shipping_method": method,
            "idempotency_key": str(uuid4()),
        }, headers=auth)
        assert response.status_code == expected_status