Test cases for dynamic array

How can I write tests for dynamic array response?

Below is the response of the API:
Sometimes I get the A response and sometimes B. Please assist.

A)
[

{

    "userSubscriptionId": "60dad8704339f88f2a694322",

    "planName": "Monthly Membership",

    "planCode": "etprMonthlyPlan",

    "subscriptionPermissionTypes": [

        "subscribed",

        "can_buy_subscription",

        "can_renew_subscription",

        "cancelled_subscription"

    ]

},

{

    "subscriptionPermissionTypes": [

        "etadfree_can_buy_subscription"

    ]

}

]

B)
[

{

    "subscriptionPermissionTypes": [

        "etadfree_can_buy_subscription"

    ]

},

{

    "userSubscriptionId": "60dad8704339f88f2a694322",

    "planName": "Monthly Membership",

    "planCode": "etprMonthlyPlan",

    "subscriptionPermissionTypes": [

        "subscribed",

        "can_buy_subscription",

        "can_renew_subscription",

        "cancelled_subscription"

    ]

}

]

Hi @gaurav.sharma1,

On checking both responses, subscriptionPermissionTypes is coming always with different values.

To put a test case on dynamic values, we must define what should we test.

If possible can you please elaborate what needs to be tested, so that we can help you with information that is more relevant than a generic one.

Hi @pranavdavar

I need to write test cases only for the values as below but as you can see, the response is changing, so path I wrote the test for, gets changed and test fails, and as soon as that location(path) comes again, the test cases are passing, so how can I handle it?

“subscriptionPermissionTypes”: [

    "subscribed",

    "can_buy_subscription",

    "can_renew_subscription",

    "cancelled_subscription"

]