Mocks not working in MUnit suite but they work when run test by test
<p>I am using Munit to test my Mule Flow and I am using mocks to set the variables so that the flow doesn't throw an exception. When I run the test on it's own it passes but when I run my full suite just that test fails and running the debug shows that the mocks don't set the variables when running as a suite.</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;mule xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mock     http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd"&gt;
&lt;munit:config name="munit" doc:name="MUnit configuration" /&gt;
&lt;spring:beans&gt;
    &lt;spring:import resource="classpath:endpointproject.xml" /&gt;
&lt;/spring:beans&gt;

&lt;munit:test
    name="test_FilePickUpFlow_CallsFileToStringTransformer_ExactlyOnce"
    description="Test"&gt;
    &lt;flow-ref name="filePickUpFlow" doc:name="filePickUpFlow" /&gt;
    &lt;mock:verify-call messageProcessor="file:file-to-string-transformer"
        times="1" doc:name="Verify Call" /&gt;
&lt;/munit:test&gt;

&lt;munit:test
    name="test_FilePickUpFlow_CallsJsonToObjectTransformer_ExactlyOnce"
    description="MUnit Test"&gt;
    &lt;flow-ref name="filePickUpFlow" doc:name="filePickUpFlow" /&gt;
    &lt;mock:verify-call messageProcessor="json:json-to-object-transformer"
        times="1" doc:name="Verify Call" /&gt;
&lt;/munit:test&gt;

&lt;munit:test name="test_FilePickUpFlow_CallsJsonParseSubFlow_ExactlyOnce"
    description="Validate calls to sub flows are being done properly "&gt;
    &lt;set-payload
        value="[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]"
        doc:name="Set Payload" /&gt;
    &lt;flow-ref name="filePickUpFlow" doc:name="filePickUpFlow" /&gt;
    &lt;mock:verify-call messageProcessor="mule:sub-flow"
        doc:name="Verify Call" times="1"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="name"
                whereValue="#[matchContains('jsonParseSubFlow')]" /&gt;
        &lt;/mock:with-attributes&gt;
    &lt;/mock:verify-call&gt;
&lt;/munit:test&gt;

&lt;munit:test name="test_httpInboundFlow_CallsSetPayload_ExactlyOnce"
    description="MUnit Test"&gt;
    &lt;flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /&gt;
    &lt;mock:verify-call messageProcessor="set-payload"
        doc:name="Verify Call" /&gt;
&lt;/munit:test&gt;

&lt;munit:test
    name="test_HttpInboundFlow_CallsJsonToObjectTransformer_ExactlyOnce"
    description="MUnit Test"&gt;
    &lt;munit:set payload="#[]" doc:name="Set Message"&gt;
        &lt;munit:inbound-properties&gt;
            &lt;munit:inbound-property key="http.query.params"
                value="ParameterMap{[json=[[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]]]}" /&gt;
        &lt;/munit:inbound-properties&gt;
    &lt;/munit:set&gt;
    &lt;flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /&gt;
    &lt;mock:verify-call messageProcessor="json:json-to-object-transformer"
        doc:name="Verify Call" times="1" /&gt;
&lt;/munit:test&gt;
&lt;munit:test name="test_HttpInboundFlow_CallsJsonParseSubFlow_ExactlyOnce"
    description="Validate calls to sub flows are being done properly "&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name"
                whereValue="#['Set Payload To Query Params']" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return
            payload="#['[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]']" /&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="json:json-to-object-transformer"
        doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="#['JSON to Object']" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return
            payload="#['[{protocol=http, host=0.0.0.0, port=8085, path=, operation=GET}]']" /&gt;
    &lt;/mock:when&gt;
    &lt;flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /&gt;
    &lt;mock:verify-call messageProcessor="mule:sub-flow"
        times="1" doc:name="Verify Call"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="name"
                whereValue="#[matchContains('jsonParseSubFlow')]" /&gt;
        &lt;/mock:with-attributes&gt;
    &lt;/mock:verify-call&gt;
&lt;/munit:test&gt;

&lt;munit:test
    name="test_HttpInboundFlow_CallsSetEndpointVariablesSubFlow"
    description="MUnit Test"&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name"
                whereValue="#['Set Payload To Query Params']" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return
            payload="#['[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]']" /&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set port variable" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="port" value="8085" /&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set path variable" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="path" value="#[]" /&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set host variable" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="host" value="0.0.0.0" /&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name"
                whereValue="set protocol variable" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="protocol" value="http" /&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name"
                whereValue="set operation variable" /&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="operation" value="GET" /&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;munit:set payload="#[]" doc:name="Set Message"&gt;
        &lt;munit:inbound-properties&gt;
            &lt;munit:inbound-property key="http.query.params"
                value="ParameterMap{[json=[[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]]]}" /&gt;
        &lt;/munit:inbound-properties&gt;
    &lt;/munit:set&gt;
    &lt;flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /&gt;
    &lt;mock:verify-call messageProcessor="mule:sub-flow"
        doc:name="Verify Call"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="name" whereValue="#[matchContains('setEndpointVariablesSubFlow')]"/&gt;
        &lt;/mock:with-attributes&gt;
    &lt;/mock:verify-call&gt;
&lt;/munit:test&gt;

&lt;munit:test name="test_HttpInboundFlow_CallsHttpEndpointSubFlow"
    description="MUnit Test"&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="#['Set Payload To Query Params']"/&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#['[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]']"/&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set port variable"/&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="port" value="8085"/&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set path variable"/&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="path" value="#[]"/&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set host variable"/&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="host" value="0.0.0.0"/&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set protocol variable"/&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="protocol" value="http"/&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;mock:when messageProcessor="mule:set-payload" doc:name="Mock"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="doc:name" whereValue="set operation variable"/&gt;
        &lt;/mock:with-attributes&gt;
        &lt;mock:then-return payload="#[]"&gt;
            &lt;mock:inbound-properties&gt;
                &lt;mock:inbound-property key="operation" value="GET"/&gt;
            &lt;/mock:inbound-properties&gt;
        &lt;/mock:then-return&gt;
    &lt;/mock:when&gt;
    &lt;munit:set payload="#[]" doc:name="Set Message"&gt;
        &lt;munit:inbound-properties&gt;
            &lt;munit:inbound-property key="http.query.params"
                value="ParameterMap{[json=[[{&amp;quot;protocol&amp;quot;:&amp;quot;http&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;0.0.0.0&amp;quot;,&amp;quot;port&amp;quot;:&amp;quot;8085&amp;quot;,&amp;quot;path&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;operation&amp;quot;:&amp;quot;GET&amp;quot;}]]]}" /&gt;
        &lt;/munit:inbound-properties&gt;
    &lt;/munit:set&gt;
    &lt;flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /&gt;
    &lt;mock:verify-call messageProcessor="mule:sub-flow"
        doc:name="Verify Call"&gt;
        &lt;mock:with-attributes&gt;
            &lt;mock:with-attribute name="name" whereValue="#[matchContains('httpEndpointSubFlow')]"/&gt;
        &lt;/mock:with-attributes&gt;
    &lt;/mock:verify-call&gt;
&lt;/munit:test&gt;
</code></pre>

<p></p>

<p>I can't see why the test would be different when a suite as I have no communication between each, do you know how I can avoid this happening?</p>

<p>The test that fails is test_HttpInboundFlow_CallsHttpEndpointSubFlow.</p>