Conditional test execution with parameterised tests

8 views
Skip to first unread message

Akshay Maldhure

unread,
Feb 13, 2020, 1:08:52 AM2/13/20
to lemoncheesecake
I would like to write a parameterised test with a JSON file containing input data like below.

I would like to feed this JSON file using @lcc.parameterised(...) to a test, but I want to execute the same test based on the run_test flag.

Is this feasible?

[
{
"input1": "a",
"input2": "b",
"run_test": true
},
{
    "input1": "c",
"input2": "d",
"run_test": false
}
]

Nicolas Delon

unread,
Feb 14, 2020, 7:11:22 AM2/14/20
to lemoncheesecake
Hello,

I'm not sure to understand your question, you want to run the test if "run_test" is true to have no test otherwise, that'is it ?

In that case, you can simply use filter for instance:
@lcc.parametrized(filter(lambda row: row["run_test"], json.loads(...)))

Regards.

Akshay Maldhure

unread,
Feb 14, 2020, 7:23:53 AM2/14/20
to lemoncheesecake
Yes, Nicolas. That's what I'm looking for. Thanks a lot.
Reply all
Reply to author
Forward
0 new messages