Hey There -- One of the reasons we are considering...
# prefect-community
d
Hey There -- One of the reasons we are considering moving to prefect is to get better testing coverage. I am looking for examples how how to test Flows including any approach to mocking out Tasks. Anyone have any pointers?
c
For specifically mocking out tasks, I’d recommend using
flow.replace
which will allow you to swap out a given task with another task; at this moment Prefect doesn’t offer an off-the-shelf task mock, but now that you’ve asked I think it’s something we’ll look into! For other forms of testing (injecting state, testing triggers, etc.) check out this SO answer: https://stackoverflow.com/questions/65220781/how-to-get-in-prefect-core-local-task-final-state/65227575#65227575
I should also call out that you can test your task’s specific logic by calling
my_task.run()
with the appropriate kwargs and with any mocks you may need
👍 1
👀 2