pembertonrw
12 years agoContributor
[R]Test Failing When Running Via Test Runner But is OK in UI
We have a test that does the following:
1) Sends down a HTTP request with a json object;
2) A response is then returned than contains various bits of information;
3) The HTTP Post step has a script assert on it which confirms that the response contains certain information.
I have ran this test repeatedly and it does not fail if I kick off the test via the GUI, however when I run this test via the testrunner it fails on the assert for the reason:
I can see in the logs that the response does contain the information I require. The following seems to be thrown:
An example of what I have done in the script assert is:
I have confirmed that this is happening in both version 4.5.2 and 4.6.0.
1) Sends down a HTTP request with a json object;
2) A response is then returned than contains various bits of information;
3) The HTTP Post step has a script assert on it which confirms that the response contains certain information.
I have ran this test repeatedly and it does not fail if I kick off the test via the GUI, however when I run this test via the testrunner it fails on the assert for the reason:
java.lang.Exception: Script Assertion in [012 - Send HTTP Test Request] failed;
[null]
Status: FAILED
Time Taken: 206
Size: 3204
Timestamp: Fri Oct 11 10:35:54 BST 2013
TestStep: 012 - Send HTTP Test Request
----------------- Messages ------------------------------
[Script Assertion] null
I can see in the logs that the response does contain the information I require. The following seems to be thrown:
---------------- Response --------------------------
X-AspNet-Version: [4.0.30319]
X-AspNetMvc-Version: [4.0]
Date: [Fri, 11 Oct 2013 09:35:54 GMT]
#status#: [HTTP/1.1 200 OK]
Content-Length: [3204]
Content-Type: [application/json; charset=utf-8]
X-Powered-By: [ASP.NET]
Server: [Microsoft-IIS/8.0]
Cache-Control: [private, s-maxage=0]
{"item":{"attribute1":"x","attribute2":"z"},"someitem":{"id":"33AF2B9A-97C7-11E2-A454-08002751B47E","content":"<messageData><item>item</item><state>NORMAL</state>"}}
at com.eviware.soapui.tools.SoapUITestCaseRunner.throwFailureException(SoapUITestCaseRunner.java:531)
at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:433)
at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:158)
at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:89)
at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:115)
An example of what I have done in the script assert is:
import groovy.json.JsonSlurper
//Get Properties
def targetStep = messageExchange.modelItem.testStep.testCase.getTestStepByName( "001 - Properties" )
def response = messageExchange.response.responseContent
def slurper = new JsonSlurper()
def json = slurper.parseText response
def someitemContent = targetStep.getPropertyValue('someitemContent') as String;
def someitemId = targetStep.getPropertyValue('someitemId') as String;
//verify 1st document present in the request
assert json.someitem.id == someitemId
assert json.someitem.content == someitemContent
I have confirmed that this is happening in both version 4.5.2 and 4.6.0.