GMSoapUI
12 years agoContributor
[Resolved] Manual test execution works, automation does not.
I have an issue with some inconsistent test results. I will explain the scenario and then what is different between a manual execution and an automated execution.
My scenario involves executing PUT / GET / POST and DELETE methods at a specific endpoint. I am trying the following:
PUT - specifying a device ID
PUT - without specifying a device ID
GET - specifying a device ID
GET - without specifying a device ID
DELETE - specifying a device ID
DELETE - without specifying a device ID
POST - create a new device
POST - update an existing device
The results I expect are as follows:
PUT - specifying a device ID - FAIL
PUT - without specifying a device ID - PASS
GET - specifying a device ID - PASS
GET - without specifying a device ID - PASS
DELETE - specifying a device ID - PASS
DELETE - without specifying a device ID - FAIL
POST - create a new device - PASS
POST - update an existing device - PASS
On each test I have one or more assertions so, if the two tests above fail with the right HTTP response they actually pass my test if that makes sense.
When I run the tests sequentially manually everything work as I expect. When I run the test suite everything also works as I expect. When I run the tests via a driver script written in Groovy I get the following failures, which I do not expect:
GET - specifying a device ID - FAIL
POST - update an existing device - FAIL
In between some of the tests I am performing property transfers of the device ID. The full execution therefore looks like this:
PUT - specifying a device ID - FAIL
PUT - without specifying a device ID - PASS
Device ID Property Transfer #1
GET - specifying a device ID - PASS
GET - without specifying a device ID - PASS
Device ID Property Transfer #2
DELETE - specifying a device ID - PASS
DELETE - without specifying a device ID - FAIL
POST - create a new device - PASS
Device ID Property Transfer #3
POST - update an existing device - PASS
To reiterate, when running these sequentially manually or at test suite level, this all works fine and the property transfers occur successfully.
When running this via the driver script I am doing nothing elaborate other than running the tests by name within the test suite - i.e. nothing different to what pressing the green play arrow icon in the test suite does.
I can see why the tests are failing but I do not understand the reason for the failure and I hoping someone can assist me.
My assertion for the failed test step 'GET - specifying a device ID' is checking the response element irrespective of the namespace and looks like this:
-------------------
//*:Response[1]
-------------------
<Response xmlns="${#Project#prop_ServiceEndpoint}/accounts/${#Project#prop_Account_1}/devices/${GET - With Device ID#Id}">
<AccountID>${#Project#prop_Account_1}</AccountID>
<Description/>
<DeviceID>${GET - With Device ID#Id}</DeviceID>
<Number>${#Project#prop_Number_1}</Number>
<Order>*</Order>
<PIN null="true"/>
<Verified>true</Verified>
</Response>
-------------------
As you can see I have parameterised the namespace in the response. The part that is failing is the ${GET - With Device ID#Id} part in the namespace. It is seemingly not holding any value at the point the assertion is made. For example the actual namespace in the response is 'https://<url>/accounts/<account_number>/devices/123' (please not, I have replaced sensitive information with placeholders in angled brackets). But the part it tries to match against is 'https://<url>/accounts/<account_number>/devices/' - i.e. it does not have the device identifier. I have got similar tests in other endpoints and they all work fine with the Groovy script and parameters in the namespace but for some reason this one is misbehaving.
The other unexpected test failure - 'POST - update an existing device' fails on an assertion which only checks the HTTP response code. If I run it manually it works and gets the right HTTP response, but if I use the Groovy script it comes back with a 500. When I execute it manually immediately after it fails, it works. I have checked the back-end databases and the information that should be present is there and so this is not a database or other server issue.
In both of these unexpected failures I can see that the property transfer test step has executed successfully and the value has been passed into the right place but execution still fails. I have spent an inordinate amount of time on this and I cannot fathom what the problem is. Everything points to the Groovy script being incorrect but I am not doing anything other than looping through the test steps within the test case and executing them in sequential order - nothing different than what is being done when I manually execute them myself or run them at the test suite level.
The assertion error I receive on the first failed test, is:
XPathContains assertion failed for path [//*:Response[1]] : Exception:org.custommonkey.xmlunit.Diff
[different] Expected namespace URI 'https://<url>/accounts/<account_number>/devices/' but was 'https://<url>/accounts/<account_number>/devices/978' - comparing <Response...> at /Response[1] to <Response...> at /Response[1]
Please note, I have once again replaced sensitive information with placeholders in angled brackets.
I had thought the issue might be one of timing since the Groovy script executes very fast indeed but I have put in delay steps of varying lengths and I consistently receive the same responses.
Could anyone shed any light on this? Unfortunately I cannot post the Groovy script as my company would not allow it but it is not complicated. In essence the execution code is essentially as follows:
Yet the results of this differ from manually executing the same test steps.
Any help would be greatly appreciated.
My scenario involves executing PUT / GET / POST and DELETE methods at a specific endpoint. I am trying the following:
PUT - specifying a device ID
PUT - without specifying a device ID
GET - specifying a device ID
GET - without specifying a device ID
DELETE - specifying a device ID
DELETE - without specifying a device ID
POST - create a new device
POST - update an existing device
The results I expect are as follows:
PUT - specifying a device ID - FAIL
PUT - without specifying a device ID - PASS
GET - specifying a device ID - PASS
GET - without specifying a device ID - PASS
DELETE - specifying a device ID - PASS
DELETE - without specifying a device ID - FAIL
POST - create a new device - PASS
POST - update an existing device - PASS
On each test I have one or more assertions so, if the two tests above fail with the right HTTP response they actually pass my test if that makes sense.
When I run the tests sequentially manually everything work as I expect. When I run the test suite everything also works as I expect. When I run the tests via a driver script written in Groovy I get the following failures, which I do not expect:
GET - specifying a device ID - FAIL
POST - update an existing device - FAIL
In between some of the tests I am performing property transfers of the device ID. The full execution therefore looks like this:
PUT - specifying a device ID - FAIL
PUT - without specifying a device ID - PASS
Device ID Property Transfer #1
GET - specifying a device ID - PASS
GET - without specifying a device ID - PASS
Device ID Property Transfer #2
DELETE - specifying a device ID - PASS
DELETE - without specifying a device ID - FAIL
POST - create a new device - PASS
Device ID Property Transfer #3
POST - update an existing device - PASS
To reiterate, when running these sequentially manually or at test suite level, this all works fine and the property transfers occur successfully.
When running this via the driver script I am doing nothing elaborate other than running the tests by name within the test suite - i.e. nothing different to what pressing the green play arrow icon in the test suite does.
I can see why the tests are failing but I do not understand the reason for the failure and I hoping someone can assist me.
My assertion for the failed test step 'GET - specifying a device ID' is checking the response element irrespective of the namespace and looks like this:
-------------------
//*:Response[1]
-------------------
<Response xmlns="${#Project#prop_ServiceEndpoint}/accounts/${#Project#prop_Account_1}/devices/${GET - With Device ID#Id}">
<AccountID>${#Project#prop_Account_1}</AccountID>
<Description/>
<DeviceID>${GET - With Device ID#Id}</DeviceID>
<Number>${#Project#prop_Number_1}</Number>
<Order>*</Order>
<PIN null="true"/>
<Verified>true</Verified>
</Response>
-------------------
As you can see I have parameterised the namespace in the response. The part that is failing is the ${GET - With Device ID#Id} part in the namespace. It is seemingly not holding any value at the point the assertion is made. For example the actual namespace in the response is 'https://<url>/accounts/<account_number>/devices/123' (please not, I have replaced sensitive information with placeholders in angled brackets). But the part it tries to match against is 'https://<url>/accounts/<account_number>/devices/' - i.e. it does not have the device identifier. I have got similar tests in other endpoints and they all work fine with the Groovy script and parameters in the namespace but for some reason this one is misbehaving.
The other unexpected test failure - 'POST - update an existing device' fails on an assertion which only checks the HTTP response code. If I run it manually it works and gets the right HTTP response, but if I use the Groovy script it comes back with a 500. When I execute it manually immediately after it fails, it works. I have checked the back-end databases and the information that should be present is there and so this is not a database or other server issue.
In both of these unexpected failures I can see that the property transfer test step has executed successfully and the value has been passed into the right place but execution still fails. I have spent an inordinate amount of time on this and I cannot fathom what the problem is. Everything points to the Groovy script being incorrect but I am not doing anything other than looping through the test steps within the test case and executing them in sequential order - nothing different than what is being done when I manually execute them myself or run them at the test suite level.
The assertion error I receive on the first failed test, is:
XPathContains assertion failed for path [//*:Response[1]] : Exception:org.custommonkey.xmlunit.Diff
[different] Expected namespace URI 'https://<url>/accounts/<account_number>/devices/' but was 'https://<url>/accounts/<account_number>/devices/978' - comparing <Response...> at /Response[1] to <Response...> at /Response[1]
Please note, I have once again replaced sensitive information with placeholders in angled brackets.
I had thought the issue might be one of timing since the Groovy script executes very fast indeed but I have put in delay steps of varying lengths and I consistently receive the same responses.
Could anyone shed any light on this? Unfortunately I cannot post the Groovy script as my company would not allow it but it is not complicated. In essence the execution code is essentially as follows:
for( testStep = 0; testStep < testCase.getTestStepCount(), testStep++ )
{
testRunner.runTestStep( testCase.getTestStepAt( testStep ) );
}
Yet the results of this differ from manually executing the same test steps.
Any help would be greatly appreciated.