Deduplication Rules

You can choose which request parameters to exclude or include while deduplication is done

By creating a deduplication rule you can reduce the number of requests to run in a test by excluding a randomized or an irrelevant parameter that is a part of a large number of requests.

Let's take the example of a Session from the previous section to understand better:

No.PathPayload
1

GET /api/v1/products/5

Query: {

"lang": "en"

}

2

GET /api/v1/products/6

Query: {

"lang": "en"

}

3

GET /api/v1/products/5

Query: {}

4

GET /api/v1/products/8

Query: {

"lang": "fe"

}

5

GET /api/v1/products/6

Query: {

"lang": "en"

}

In this example we can see query parameter "lang" is not consistent in payloads and it's not a required parameter for the products API, it could very well be meta information that has little to no effect on the business logic of the API.

By default HyperTest will consider these parameters while deduplicating:

  • Path parameters

  • Query parameters

  • Body parameters

Let's create a rule to exclude the query parameter "lang".

To create a rule we will open the deduplication rules page under Settings and click on the Add Deduplication Rule button.

Upon opening the dialog you will see a bunch of fields, let's take them one by one and try to understand.

On the top left corner, you have the HTTP methods field, here you can specify the method type of your API for which you wish to create a rule, ANY is also an option so you can apply this rule to all the HTTP methods.

In our case, we want to create a rule for a "GET" API so we will select that.

Next, we have API Path, here we can mention an exact API path or we can pass a Regular Expression or a URL pattern.

Regular Expression needs a prefix keyword "REGEX:" After this, you write your expression and HyperTest will match request paths against that. Example:

REGEX:^\/api\/v1\/products\/(\d+)(\/|)$

URL pattern for this API would be:

/api/v1/products/:id

For more information on URL patterns please refer to this documentation: https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API

Let's go with the URL pattern because it's much easier to understand and it satisfies our use case, you can any one of them but using Regular Expression would be warranted for complex use cases where you would want to match requests based on a prefix or a particular keyword.

Next, we have a checkbox called "Should not deduplicate", you can select it if you don't want requests of an API to be deduplicated, In our case, we want to exclude some parameters of a request from the deduplication process so we definitely don't need this right now.

This option is very useful in a case where you want to run a login request with the same payload multiple times to successfully test your scenario, in this case, you should create a rule to not deduplicate login requests while HyperTest will be deduplicating other requests.

Let's look at the rest of the fields provided:

  • Query Exceptions: Here we provide the names of query parameters that you do not want to consider for deduplication.

  • Body Exceptions: Provide the paths of body parameters that you do not want to consider for deduplication e.g., "user.metaInfo.currLocation"

  • Headers Whitelist: By default, headers are not considered but you can provide the name of the headers that should be considered for deduplication.

  • Cookies Whitelist: By default, cookies are not considered but you can provide the name of the cookies that should be considered for deduplication.

In our case, we just want to remove the query parameter "lang" from the deduplication process for our API: GET /api/v1/products/:id

Let's finish creating this rule:

Now with this rule in place let's look at what happens to our sample Session:

Total Request count: 5

Without deduplication, all Requests are selected.

No.PathPayloadIncluded In Test
1

GET /api/v1/products/5

Query: {

"lang": "en"

}

2

GET /api/v1/products/6

Query: {

"lang": "en"

}

3

GET /api/v1/products/5

Query: {}

4

GET /api/v1/products/8

Query: {

"lang": "fe"

}

5

GET /api/v1/products/6

Query: {

"lang": "en"

}

Last updated