tracetest icon indicating copy to clipboard operation
tracetest copied to clipboard

Add variables to test triggers

Open mrwatson opened this issue 3 years ago • 6 comments

Is your feature request related to a problem? Please describe. Our potential use case involves sending API calls that have varying data in the request body (i.e., randomly generated names or IDs) because the call will fail if run twice with the same variables in the request unless the database is somehow cleaned up in between calls.

Describe the solution you'd like Provide a means to include variables in the request that would be dynamically replaced at run-time. The variables could be specified by the user when the test is triggered or could be generated dynamically by the test itself (such as generating a UUID - Insomnia has a similar feature, for comparison).

Describe alternatives you've considered Dynamically generating the entire test as a YAML file. This would work, but is significantly more effort.

Additional context N/A

mrwatson avatar Jul 20 '22 19:07 mrwatson

That's definitely something that we need. I'm thinking about using some kind of syntax: #{uuid}, #{name}, etc. We can use gofakeit to generate those values for us.

I don't see much value in enabling that kind of data generation in the assertions though. Do you see any value in it or should we only enable that in the triggering transaction request?

mathnogueira avatar Jul 20 '22 20:07 mathnogueira

Currently, I only see value for data generation on the triggering side. On the assertion side, it would be nice to be able to test against variables, though (see #950).

mrwatson avatar Jul 20 '22 21:07 mrwatson

Yes, currently we only support data generation on the triggering side. I'm planning to start working on adding support to data generation probably on Monday.

mathnogueira avatar Jul 20 '22 22:07 mathnogueira

About supporting variables, we have the goal of adding support for both variables and expressions: #782

mathnogueira avatar Jul 20 '22 22:07 mathnogueira

@mathnogueira one concept I believe we will want to add is 'adhoc' running of transactions. Think of it as manual testing - I am developing and need to exercise the api and see oth the response and the trace output. We will want to be able to save these and run them when needed. It will make sense to allow a variable to be passed in or set... so variables may end up helping with that scenario

kdhamric avatar Jul 28 '22 12:07 kdhamric

Hey @mrwatson we just released v0.6.4 and it introduces the concept of generator functions which are functions that generate random data in your test trigger section.

You can read more about it in the generator functions section of in this doc page.

mathnogueira avatar Aug 19 '22 20:08 mathnogueira

@mrwatson if you feel this doesn't solve your problem. Feel free to open a new issue.

mathnogueira avatar Jan 25 '23 22:01 mathnogueira

Okay, thanks guys. We'll take a look when we get back around to trying this again.

mrwatson avatar Jan 25 '23 22:01 mrwatson