[Idea] Mark TC Variables as "Required"

It will be very useful if when adding a variable, that you can mark it as ‘required’. Then if the test case is executed and the variable has not been assigned to by the caller, katalon could automatically log an error stating “Required variable ‘name’ was not passed in” etc.

I know we can write our own if (name == “”) statement and markFailed, but that gets very tedious doing that all the time.

Sounds reasonable on the face of it – not sure if it makes sense under the hood though. Let’s see what the developers say.

Moved to Feature Requests.

aside I have to admit, I’ve never quite understood the benefit of TC variables. I get it from a callTestCase perspective, but not statically defined in the Variables view. It must be some kind of workflow I’ve never needed. :confused:

I am not sure what will be the benefit of this.
Basicaly when you define a variable in a testcase, it gets a default value (which may be empty).
So calling a test case without passing a binded value will run the called tescase with the default value.
Marking it as ‘required’ may potentialy break other use cases if not used carefully (in my understanding this equals with a class or method having a variable in the signature without a default valure, therefore it is mandatory to be passed when calling it)
@AndyG72 can you add more context into this? E. g. describe some posible workflows.
I am affraid that having such feature in place will create more problema than solving if not used properly

My concern was backwards compatibility. But let’s see…

That too, because under the hood will affect how the groovy script binding mechanism works… But with more details about the intended usage… Who knows, maybe we will like it

@anon46315158

It is mostly for having a test case that is used to fill out a form.

The form may have a number of required fields and each field in the form will have a corresponding variable passed in.

If the user has not passed in a required field, the test will of course fail when the form is submitted, which is fine.

But if the required variables in the test case could be marked as ‘required’ when the variables are added in the usual way, it would just save us the time of writing an ‘if’ statement that checks if the variable has been passed in and the subdequent ‘markFailed’ etc.

The engine could pretty much take care of that failure/log message for us.

It is really only a question of speed of workflow for the people creating the tests. It is something I have seen in another test automation product that I thought was quite neat, but I can certainly work without it.

If such a think was added, I would expect it to default to false for backward compatibility etc.