Mule测试最佳做法和功能与单元 [英] Mule testing best practices and functional vs unit
问题描述
我正在寻找有关测试Mule应用程序的最佳实践的一些指导.
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.
然后我使用Munit模拟流引用,以便对流进行隔离测试.
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.
这是测试Mule应用程序的有效方法吗?
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?
推荐答案
您所做的是正确的!
您可以根据实际需要对代码进行尽可能多的划分,即使用流和子流,主要是因为这是常识. Ť 再次,您不应该仅仅因为这些而尝试将所有内容拆分为子流.
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.
关于单元与功能,我不认为它应该是"Vs".他们是相辅相成的.您应该始终尝试进行单元测试和功能/集成测试.
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.
最后,您可以进行不同程度的测试. 您可以模拟所有流引用,然后可以仅模拟对外部端点的调用,或者根本不模拟任何事情来进行端到端集成,并使用Munit的before/after测试和before/after套件进行补偿.集成测试的交易.
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.
希望这会有所帮助
这篇关于Mule测试最佳做法和功能与单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!