title: Assert a SoapUI test case with reason of failure
body: <p>I have a test case on which I want to put the assertion. </p>
  
  <p>I need to provide a reason for failure in assertion. </p>
  
  <p>My output from XML format is as follow:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soapenv:Body&gt;
        &lt;soapenv:Fault&gt;
           &lt;faultcode&gt;soapenv:Server&lt;/faultcode&gt;
           &lt;faultstring&gt;XYZ-001: input is wrong&lt;/faultstring&gt;
           &lt;detail&gt;
              &lt;con:fault xmlns:con="http://www.bea.com/wli/sb/context"&gt;
                 &lt;con:errorCode&gt;XYZ-001&lt;/con:errorCode&gt;
                 &lt;con:reason&gt;input is wrong&lt;/con:reason&gt;
                 &lt;con:location&gt;
                    &lt;con:node&gt;PipelinePairNode1&lt;/con:node&gt;
                    &lt;con:pipeline&gt;PipelinePairNode1_response&lt;/con:pipeline&gt;
                    &lt;con:stage&gt;stage1&lt;/con:stage&gt;
                    &lt;con:path&gt;response-pipeline&lt;/con:path&gt;
                 &lt;/con:location&gt;
              &lt;/con:fault&gt;
           &lt;/detail&gt;
        &lt;/soapenv:Fault&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>My desired result should be the <strong>faultstring</strong> node of the xml.</p>
  
  <p>For this I have tried with xpath assertion using this code:</p>
  
  <pre><code>declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
  declare namespace con='http://www.bea.com/wli/sb/context';
  boolean('/soapenv:Envelope/soapenv:Body/soapenv:Fault/')
  </code></pre>
  
  <p>and I put true as expected output. 
  After generating JUnit report it was giving some other reason:</p>
  
  <pre><code>Cancelling due to failed test step
  
  &lt;h3&gt;&lt;b&gt;Failure Failed&lt;/b&gt;&lt;/h3&gt;&lt;pre&gt;[XPath Match] XPathContains comparison failed for path [declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
  declare namespace con='http://www.bea.com/wli/sb/context';
  boolean('/soapenv:Envelope/soapenv:Body/soapenv:Fault/')], expecting [false], actual was [true]
  &lt;/pre&gt;&lt;hr/&gt;
  </code></pre>
  
  <p>I then proceed with Groovy using following script:</p>
  
  <pre><code>def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
  def requsetHolder = groovyUtils.getXmlHolder( messageExchange.requestContent )
  def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContent )
  def refNum = responseHolder.getNodeValue("soapenv:Envelope/soapenv:Body/soapenv:Fault/")
  def testrunner = context.getTestRunner();
  if (refNum != null){
      testrunner.fail("soapenv:Envelope/soapenv:Body/soapenv:Fault/faultstring")
  }
  </code></pre>
  
  <p>but no luck this time time also.
  junit failure reason was:</p>
  
  <pre><code>Cancelling due to failed test step
  
  &lt;h3&gt;&lt;b&gt;Failure Failed&lt;/b&gt;&lt;/h3&gt;&lt;pre&gt;[Script Assertion] net.sf.saxon.trans.XPathException: XPath syntax error at char 46 on line 2 in {...pe/soapenv:Body/soapenv:Fau...}:
   Unexpected token "&lt;eof&gt;" in path expression
  &lt;/pre&gt;&lt;hr/&gt;
  </code></pre>
  
  <p>so is there any way by which i can generate my custom reason in junit output using assertion in either groovy or xpath.</p>