Reputation: 887
I am looking for some guidance on what are the best practices for testing Mule applications.
For example, i am separating my logic into multiple private flows and using flow-refs to tie them together.
I am then using Munit to mock out the flow-refs so flows are tested in isolation.
This to me seems like unit testing and treats flows as methods etc.
Is this a valid approach to testing Mule application?
Should I also be writing functional tests that test these all working together without and mocked flows?
Upvotes: 2
Views: 329
Reputation: 6530
Another way is using vm connector, then you will test a specific piece of your flow.
Upvotes: 1
Reputation: 712
What you're doing is correct!
You can compartmentalise your code as much as it actually make sense, i.e. using flows and sub-flows mainly because it's common sense. T hen again you shouldn't try to split everything into sub-flows just because.
Regarding unit vs functional, I don't think it should be a "Vs". They complement each other. You should always try to do unit testing and functional/integration tests.
Finally there are different degrees of test you could have. You could mock all the flow-ref, then you could just mock only calls to external endpoints, or not mock anything at all do an end to end integration and use the before/after test and before/after suite of Munit to do the compensation transactions of your integration test.
Hope this helps
Upvotes: 5