Reputation: 31
I am new to IBM-MQ and trying to understand how we can perform unit testing on message flows.
I am aware of the tools like CA Lisa to do Service Virtualization and testing at system testing level.
But in my case I am looking for the unit testing framework like Java Junit tests where developer can create tests and required stubs to test the IBM MQ Message flows independently.
Thank You in advance.
Upvotes: 2
Views: 7129
Reputation: 111
Before going to the stage of choosing testing framework, I would suggest choosing a good testing strategy first. With IIB message flow, my suggestion is to do integration unit testing. Here
A critical justification for doing integration unit testing is to deprecate traditional unit testing (for message flows). This is because
To carry out integration unit testing strategy, there could be a variety of flavors of testing frameworks/tools that can be used. The factors for choosing one framework/tool could be open source vs commercial, high code vs medium code vs no code, etc.
Here is an example of open source + no code tool for doing integration unit testing: https://apitestbase.io/docs/en/iib-integration-unit-testing. Disclaimer: I am the tool developer.
Upvotes: 1
Reputation: 3051
Start using the MQ Messaging REST API Using the messaging REST API available in MQ V9.1.0.0 well actually V9.0.0.4 I believe.
I used to use all sort of workarounds in the past but if you want to just PUT messages on to queues and GET them off them and have MQ 9.1 installed or can install it then you can use the MQ Messaging REST API
An HTTP POST to .../ibmmq/rest/v1/messaging/qmgr/QMGR1/queue/Q1/message will PUT your message on to Q1
An HTTP DELETE to .../ibmmq/rest/v1/messaging/qmgr/QMGR1/queue/Q1/message will GET your message from Q1
I'm using Postman to do this but there is no reason you can't use SoapUI or any of your other favourite test tools.
One caveat at the moment is that you are limited to Text messages but given a very high percentage of messages are XML or JSON or CSV there's a fair chance this may fit the bill for you.
Upvotes: 1
Reputation: 2199
We write integration tests against deployed flows. We use the Spring Testframework and Junit as a base.
Here are some thoughts about our testing:
For synchronous dependencies we either write mock flows that we deploy in a separate IIB application, or we use JUnit helpers for things like SMTP and LDAP.
For asynchronous dependencies like IBM MQ we use in our tests the JmsTemplate or directly the IBM MQ classes for JMS to send and receive messages. Before each test we clean the queues with PCF messages.
For file nodes we use the environment variable MQSI_FILENODES_ROOT_DIRECTORY
in the real flow and in Junit to easily find the files. We also clean the File input and output directories before each test to start clean.
To speed up the unit tests and to test things like assert that no message arrived we subscribe in our Junit tests to Monitoring Events. When we receive the Transaction End event we are sure the flow is finished and can assert that a file is there, that no message is on a certain queue, etc.
Upvotes: 1