Query params cause combinatorial explosion in number of generated tests #730
Replies: 4 comments 4 replies
-
@yntelectual Thanks for bringing this up. I am moving this issue to a discussion format as we will need more ideas and inputs on this from you as well as other contributors and the community. This is a known problem that we have been trying to tackle. Thanks to @westse, who introduced Before going into solutioning, just wanted to step back and look at the problem with optional fields in general. The issue you have highlighted with the query parameters is an extension of the same.
If we limit the total number of combinations generated, then we may not be able to ascertain the optional nature of all fields. We are looking into creating the most meaningful combinations and bubble that to the top so that even with a low In my experience, where I hit this sort of an issue with several optional parameters and inter-parameter dependency, it may point to a API design smell. And I may explore / reevaluate my API design. That said, I do acknowledge there are API designs which need to go down this path of several optional parameters because of genuine constraints. |
Beta Was this translation helpful? Give feedback.
-
@harikrishnan83 @yntelectual i would tend to agree that restricting the number of generated test through a flag would only reduce the confidence that the provider has indeed implemented the specification correctly. I would imagine that you could reduce the number of generated tests by being more descriptive in the specification itself, i.e by adding min/max ranges for numbers, adding example request/responses and reducing the number of plain text query params in favor of enums. This should do three things:
thoughts? |
Beta Was this translation helpful? Give feedback.
-
We're exploring a few options here, and will report back soon. |
Beta Was this translation helpful? Give feedback.
-
I agree that the generated scenarios covering all allowed combinations are useful. However I believe that are many scenarios in which a perfectly valid and well designed schema offers an endpoint with a significant number of query params - which would result in such a number of tests, that it might overwhelm the test runner. Maybe the simplest solution to avoid this would be to define a global safeguard limit on number of generated tests(2000?), which if its reached would cause test run to fail with a descriptive error message, with information about number of generated scenarios per endpoint/operation - giving the user an option to restrict the number of scenarios using examples, or split the test run into multiple ones, or lifting that limit. User would be able to override this limit using a simple config property, e.g. |
Beta Was this translation helpful? Give feedback.
-
Description
Query params cause combinatorial explosion in number of generated tests. Using the existing
MAX_TEST_REQUEST_COMBINATIONS
slightly mitigates this, but most probably does not work the way most users would expect.Steps to reproduce
MAX_TEST_REQUEST_COMBINATION
to 10Expected behavior
Most intuitive outcome should be 10 total requests generated. But instead 4864 testcases are generated. Even when set to 1, there are 1024 testcases generated.
Specmatic should either set a limit to the total number of generated testcases(that the user can override) or have some other safety net mechanism so that people dont smoke their laptops(imaging your api has more of these endpoints which is very common for any enterprise app that has search/listing endpoints)
The
MAX_TEST_REQUEST_COMBINATION
could be enhanced to really cover max request combinations in total, not only with regards to enums.Beta Was this translation helpful? Give feedback.
All reactions