Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to parameterize test #2950

Open
3 tasks
ShaddyDC opened this issue Jun 21, 2024 · 0 comments
Open
3 tasks

Allow users to parameterize test #2950

ShaddyDC opened this issue Jun 21, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ShaddyDC
Copy link

ShaddyDC commented Jun 21, 2024

Problem to solve

Oftentimes I want to test the same API endpoint with a couple different options and want to verify that they all work correctly. In an ideal world, I'd want to verify for each that the individual expected behaviour is correct, but for simplicity I'm often happy just to verify that it works without causing an error.

Proposal

I think it makes most sense to have variables file-wide rather than per entry. The test would then run over the cartesian product of all options.
An example might look like this:

# Parameterized test for creating and verifying a resource

# Define the parameterized variables
type: ["book", "movie"]
status: ["available", "unavailable"]

# Test scenario
POST https://api.example.com/resources
{
    "type": "{{type}}",
    "status": "{{status}}"
}

HTTP/1.1 201
[Captures]
resource_id: jsonpath "$.id"

GET https://api.example.com/resources/{{resource_id}}

HTTP/1.1 200
{
    "id": "{{resource_id}}",
    "type": "{{type}}",
    "status": "{{status}}"
}

Extra useful would be if I could use a set of parameter instances to work together, so I can use a separate component in different places while they still all fit together. Example: type: [("archive", "zip"), ("audio", "mp3"), ("document", "pdf")], and then I can request an "archive" from an api and assert that the returned type is a "zip".

It should also be noted that care must be taken with the cartesian product as the number of tests can quickly explode. Maybe each time a random subset is tried?

Additional context and resources

Templates are already a supported feature. We can manually call hurl on a test with all variable combinations. This just unfortunately isn't great if you have a different set of variables per test and quickly bloats the invocation.

Tasks to complete

  • Decide on a design
  • Implement design
  • Document design
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant