authorjapps / authorjapps/zerocode
[Feature Request] Conditional execution of Steps
- Dominant language
- Java
- Stars
- 1k
- Forks
- 453
- Avg merge
- 7d 2h
- Merged PRs (30d)
- 5
Description
In my team we use ZeroCode to support our component tests - where we validate the integration of our components against the services it interact with (some are real others mocks).
Given our use case, not knowing if more peoples have similar needs, I would propose the following.
We use the same scenario files in different use cases and some of those require specific actions to be done prior to each test. Currently we do have a way to incorporate this in scenario files because including those actions break some use cases.
The way I see this is to have additional step properties that determine if the step is or not evaluated. Something like:
```
(...)
{
"name": "adjust setup to local execution",
"url": "com.example.my_component_component_testing.helpers.db.SQLExecutor",
"method": "sqlFileExecutorNoWait",
"request": "/setup/update_db_for_local.sql",
"assertions": {},
"apply": "${config.is_component_running_locally}"
},
(...)
```
where we implement a new optional parameter (`apply` in the example above) that by default is resolved to `TRUE` but if defined its interpretation would determine if the step would actually be executed.
In proposed example the step refers to a variable defined in the config_hosts.properties (`config.is_component_running_locally`) that would have to be interpreted to a bool value but it's execution could also be determined by a variable coming from previous steps.
For simplicity sake I am proposing that the variable value would be restricted to directly boolean values convertible strings but a discussion on more complex expressions might be worth.
Thanks for your attention.
Contributor guide
Research direction
Start by reading the scenario files and config_hosts.properties usage to trace how step properties and variables are resolved. Determine where an optional apply value could control step execution, including values from previous steps. Done means omitted apply values still execute, boolean-convertible values conditionally skip or run the step, and the behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100