jon lee
jon lee

Reputation: 887

Integration/Functional testing in Mule when using cloud connectors

I have a Mule app that uses a few cloud connectors - Twitter and Facebook mainly. When testing my app, I don't actually want to post to my Twitter or Facebook. What is the best way to functionally/integration test this? Should I setup dummy user accounts at these sites to use for testing? Or should I use a mocking framework to mock the twitter4j response etc? And how I can I handle the OAuth aspect of it?

Upvotes: 1

Views: 270

Answers (1)

David Dossot
David Dossot

Reputation: 33413

Take a look at munit, an test framework MuleSoft is currently building and that allows mocking cloud connectors.

Here is an excerpt of an example where they mock the Mongo cloud connector:

<munit:test name="afterFtpPollingSaveUser" description="Mongo must be called correctly">
    <mock:when messageProcessor="mongo:add-user" />

    <mock:spy messageProcessor="mongo:add-user">
        <mock:assertions-before-call>
            <munit:assert-not-null/>
        </mock:assertions-before-call>

        <mock:assertions-after-call>
            <munit:assert-not-null/>
        </mock:assertions-after-call>
    </mock:spy>

    <munit:set payload-ref="#[getResource('users.xml').asStream()]" />

    <flow-ref name="mongo-storage" />

    <mock:verify-call messageProcessor="mongo:add-user" times="2"/>
</munit:test>

Upvotes: 1

Related Questions