Announcement Announcement Module
No announcement yet.
Unit Test best practice Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unit Test best practice

    I'm currently using SI 1.0.3

    Are there any recommendations for unit testing Spring Integration flows?

    Right now I'm basically testing the entire flow but that is becoming unmanageable.

    I would like to test at a more granular level.
    I would like to isolate certain input channels, channel adapters and output channels.
    I would like to write tests to cover all the conditions that could occur in that mini flow.
    Right now I'm thinking that my mini-flow tests would be made up of a mini-flow context file, java code that builds messages and code that tests for the expected output.
    I would have individual tests which would send specific messages to test each possible condition that could occur in the mini flow.

    My problem is that I'm not sure how to do that in a reasonable way without cut-and-pasting the "mini flow" from the larger actual context file into a more isolated test context file.

    I don't like that approach for the obvious reason that the real flow and the mini test flows are bound to get out of sync due to the annoyance of making changes to two places.

    Right now I do some of this type of testing by changing the real context file and modifying input channels and output channels to short circuit some of the overall flow. Obviously that is for isolated tests which I can't automate.

    Any suggestions would be appreciated.

  • #2
    Spring Integration in Action has a chapter on this topic that is part of the early access program right now. It describes (among other things) how you can use mocks to stop a message in the middle of the flow. If you don't feel like buying the book, you could also go over the example code which is on github.