Workflow testing
Writing down end to end tests for your workflow is essential for several important reasons:
Verification of Correctness: Tests serve as a means to verify that your workflow functions correctly. They help ensure that analysis produces the expected results.
Error Detection: Tests help detect errors and issues within the workflow early in the development process. Identifying and addressing these errors before deploying the workflow for real-world tasks can prevent costly mistakes.
Regression Testing: As your workflow evolves, changes and improvements may be made. Without tests, it's challenging to ensure that new changes do not inadvertently break existing functionality.
Documentation and Understanding: Tests can serve as documentation for how your workflow should behave. They provide clear examples of expected inputs, outputs, which can help other team members understand and collaborate on the workflow.
Refactoring and Maintenance: Tests make it safer to refactor or update your workflow. When you need to make changes to the workflow's logic or structure, tests provide confidence that you haven't introduced new issues or regressions.
In summary, creating tests for your workflow is a fundamental practice !
Try writing down the tests at the same time you are doing the implementation. You should aim to have around 5 to 10 tests per task-groups.
Yaml test format
To be executed correctly, the file name should start with 'tests_v2_. .. .yaml' and be placed in a tests
folder.
The first key is the name of the test work-order. For each test work-order you can then specify:
Using the key
work_order_types
: The work order types of the test work order, as a list.Using the key
wo_metadata
: The metadata to add to the test work-order.Using the key
tests
: The list of test analysis to execute
For each test analysis you need to specify:
Using the
task_group
key: The task-group name to be analysedUsing the
inputs
key: All the inputs that are to be analysedUsing the
tasks
key: The expected tasks valuesUsing the
type
key: If there are no tasks and araw_exec
value is expectedUsing the
expected_memory
key: The expected analysis result
Here is an example of a test_work_order_all_ok
work order, which includes two tests: closing_read_all_inputs
and opening_read_all_inputs
, with the second one being of type raw_exec:
For now, prefix your test files with the string 'tests_v2' and put them in a tests folder next to the workflow_v2 folder.
Launch the tests
The command wf_client test
can be used to start the execution of the tests.
By default, pytest captures all stdout/stderr outputs. You can ddd the flag -s
to see them, which can be useful for debugging purposes.
The tests are to be specified in a yaml file. The name of the file should start with tests a The first key is the name of the test work-order. For each test work-order you can then specify:
Last updated