Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Unit Testing of Durable Functions #515

Open
Cho-William opened this issue Jul 22, 2024 · 0 comments
Open

Enable Unit Testing of Durable Functions #515

Cho-William opened this issue Jul 22, 2024 · 0 comments
Labels
Enhancement Feature requests.

Comments

@Cho-William
Copy link

💡 Feature description

What would you like to see, and why?

I've been developing a few durable functions, and I've come to realize that there is no real way to mock a azure.durable_functions.DurableOrchestrationContext object. It would be ideal if we could have this available to unit test durable functions. The current documentation seems to expect the developer to just run a local integration test.

What kinds of usage do you expect to see in this feature?

Per above, mocking the orchestration context would allow unit-testing of durable functions.

💭 Describe alternatives you've considered

What are other ways to achieve this? Have you thought of alternative designs or solutions?

For now, I am resorting to just defining test classes that perform the core actions of my durable functions without requiring a context object. These test classes interface with Azurite to mock up necessary containers.

Any existing workarounds? Why are they not sufficient? We'd like to know!

This was rather naive, but I tried debugging a manual integration test and copying the context's json string, then feeding it to the client constructor in my unit testing. I will note that this would not even work in theory, since the context json values are tied to dynamically created resources.

Additional context

Add any other context or screenshots about the feature request here.

Question: what is the current guidance for testing durable functions, besides manually performing an integration test?
Question: is the following approach valid to emulate unit-testing: refactoring logic that does not require a context to separate classes so that they are accessible for unit-testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Feature requests.
Projects
None yet
Development

No branches or pull requests

2 participants