Forum Discussion

MODA_Health__Su_1's avatar
MODA_Health__Su_1
Occasional Contributor
11 years ago

Scripted assertions in JDBC Requests - Issue

Hello,

I have a test case with 8 steps - Data source, Groovy script, SOAP request, Delay, Groovy script, JDBC request1, JDBC Request2 and Data source loop. In each of the JDBC requests, I have a scripted assertion. I have a strange issue. If in any iteration, if the scripted assertion in any of the JDBC requests fail, In the next iteration, the same test step is marked as Failed though there is no issue and the assertions also pass. The later iterations are fine. If test step 6 fails in iteration 4, the same test step again fails in iteration 5 though all the assertions pass.

Following are the scripted assertions in my JDBC Requests.

Assertion in JDBC Request 1 -

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
def totalRows = holder.getNodeValue('//Results/ResultSet/Row/TOTALROWS')
def expectedResult = context.expand( '${GetDataForGM#ExpectedResult}' )
def messageID = context.expand( '${JDBC_Request1#messageID}' )

if (expectedResult == "Pass") {
assert totalRows.toInteger() >= 1
}
else if (expectedResult == "Fail"){
assert totalRows.toInteger() == 0
}


Assertion in JDBC Request 2 -

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
def totalRows = holder.getNodeValue('//Results/ResultSet/Row/TOTALROWS')
def expectedResult = context.expand( '${GetDataForGM#ExpectedResult}' )
def messageID = context.expand( '${JDBC_Request2#messageID}' )

if (expectedResult == "Pass"){
assert totalRows.toInteger() == 0
}
else if (expectedResult == "Fail") {
assert totalRows.toInteger() >= 1;
}



Also wanted to add - This is very random and happens most of the times.
sometimes, if I make changes to the scripted assertions like adding a log statement or changing the else if to if statement, it works fine but resurfaces after some time. does this have anything with the cache? Once this issue occurs, it occurs even if I exit soapui Pro and get back in.
I posted the same earlier on Community forum too before I dug out my pro login credentials. I apologize.

14 Replies

  • MODA_Health__Su_1's avatar
    MODA_Health__Su_1
    Occasional Contributor
    I am using version 4.5.2. I have tried everything from re-installing SoapUI Pro to recreating the tests. It still fails.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    I have also tried to reproduce your issue with almost exact setup but no luck.

    I understand it is a bit frustrating, at the same time we are also unable to help you unless we can reproduce this issue.

    I would suggest that you try building a simplified version of your project and then gradually add things and see at what point you start reproducing this issue. At that point it is probably easier to see what might have causing this. If you want I can also share my project with you.

    Regards,
    Shadid
    SmartBear Sweden.
    • aw-iqa's avatar
      aw-iqa
      Frequent Visitor

      I am having a similar issue using ReadyAPI v2.8.2

       

      I have a JDBC Request step which has a JDBC Status Assertion.

      After that I have an XQuery Assertion using the ResponseAsXml from the JDBC Request step.

       

      This is driven by a Data Source and Data Source Loop.

      If any JDBC Request fails, the JDBC Status Assertion fails, and will continue to report as failed for the rest of the test loop. The Assertion passes as expected.

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Hi aw-iqa! This seems to be a very old thread. Did you face a similar issue and were you able to find a solution?

        Please feel free to create a new thread if you still have any questions to the Community! Thank you!