Tracing incoming/outgoing messages

As we deal with message based interfaces Citrus will send and receive a lot of messages during a test run. Now we may want to see these messages in chronological order as they were processed by Citrus. We can enable message tracing in Citrus in order to save messages to the file system for further investigations.

Citrus offers an easy way to debug all received messages to the file system. You need to enable some specific loggers and interceptors in the Spring application context.

<bean class=""/>

Just add this bean to the Spring configuration and Citrus will listen for sent and received messages for saving those to the file system. You will find files like these in the default test-output folder after the test run:

For example:


Each Citrus test writes a .msgs file containing all messages that went over the wire during the test. By default the debug directory is set to logs/trace/messages/ relative to the project test output directory. But you can set your own output directory in the configuration

<bean class="">
  <property name="outputDirectory" value="file:/path/to/folder"/>

Note As the file names do not change with each test run message tracing files may be overwritten. So you eventually need to save the generated message debug files before running another group of test cases.

Lets see some sample output for a test case with message communication over SOAP Http:

Sending SOAP request:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="">
<Operation xmlns="">sayHello</Operation>
<ns0:HelloRequest xmlns:ns0="">
    <ns0:Text>Hello WebServer</ns0:Text>


Received SOAP response:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="">
<ns0:HelloResponse xmlns:ns0="">
    <ns0:Text>Hello Christoph</ns0:Text>

For this message tracing to work we need to add logging listeners to our sender and receiver components accordingly.

<citrus-ws:client id="webServiceClient"

    <util:list id="clientInterceptors">
        <bean class=""/>

Important Be aware of adding the Spring util XML namespace to the application context when using the util:list construct.