cancel
Showing results for 
Search instead for 
Did you mean: 

Scripted assertions in JDBC Requests - Issue

Highlighted
Occasional Contributor

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 14
Highlighted
Occasional Contributor

Re: Scripted assertions in JDBC Requests - Issue

Attached are some screen shots of the results.

Following is the script log
first Part is the one for the failed iteration.
Second one is for the next iteration where it has been asserted successfully. but the test step status shows failed.

Wed Jul 10 15:36:54 PDT 2013:INFO:*****Checking ODS_HIX_GROUPSETUP_MAINTENANCE*****
Wed Jul 10 15:36:54 PDT 2013:INFO:messageID - 1373495811314
Wed Jul 10 15:36:54 PDT 2013:INFO:Expected Result - Pass
Wed Jul 10 15:36:54 PDT 2013:INFO:Number of Rows fetched- 0
Wed Jul 10 15:36:54 PDT 2013:ERROR:Inside Pass
Wed Jul 10 15:36:54 PDT 2013:INFO:*****Checking ODS_HIX_REJECTION*****
Wed Jul 10 15:36:54 PDT 2013:INFO:messageID - 1373495811314
Wed Jul 10 15:36:54 PDT 2013:INFO:Number of Rows Fetched - 0
Wed Jul 10 15:36:54 PDT 2013:INFO:Expected Result - Pass
Wed Jul 10 15:36:54 PDT 2013:INFO:Inside PAss
Wed Jul 10 15:36:54 PDT 2013:INFO:Asserted successfully
Wed Jul 10 15:36:54 PDT 2013:INFO:*****Completed checking ODS_HIX_REJECTION*****
Wed Jul 10 15:36:54 PDT 2013:INFO:==============================================
Wed Jul 10 15:36:57 PDT 2013:INFO:*****Checking ODS_HIX_GROUPSETUP_MAINTENANCE*****
Wed Jul 10 15:36:57 PDT 2013:INFO:messageID - 1373495814549
Wed Jul 10 15:36:57 PDT 2013:INFO:Expected Result - Pass
Wed Jul 10 15:36:57 PDT 2013:INFO:Number of Rows fetched- 1
Wed Jul 10 15:36:57 PDT 2013:ERROR:Inside Pass
Wed Jul 10 15:36:57 PDT 2013:ERROR:Asserted Successfully
Wed Jul 10 15:36:57 PDT 2013:INFO:*****Completed checking ODS_HIX_GROUPSETUP_MAINTENANCE*****
Wed Jul 10 15:36:57 PDT 2013:INFO:===========================================================
Wed Jul 10 15:36:57 PDT 2013:INFO:*****Checking ODS_HIX_REJECTION*****
Wed Jul 10 15:36:57 PDT 2013:INFO:messageID - 1373495814549
Wed Jul 10 15:36:57 PDT 2013:INFO:Number of Rows Fetched - 0
Wed Jul 10 15:36:57 PDT 2013:INFO:Expected Result - Pass
Wed Jul 10 15:36:57 PDT 2013:INFO:Inside PAss
Wed Jul 10 15:36:57 PDT 2013:INFO:Asserted successfully
Wed Jul 10 15:36:57 PDT 2013:INFO:*****Completed checking ODS_HIX_REJECTION*****
Wed Jul 10 15:36:57 PDT 2013:INFO:==============================================
Highlighted

Re: Scripted assertions in JDBC Requests - Issue

Hi,

Thank you for the detailed error report, and I'm sorry you're experiencing this peculiar issue. If you look at the error log tab at the bottom of the page, does it contain anything when the assertion starts failing?

Regards,
Arian
Developer, SmartBear Sweden

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️Please mark my answer as a solution if it was helpful
Highlighted
Occasional Contributor

Re: Scripted assertions in JDBC Requests - Issue

The error log is empty. And just to reiterate, the assertion fails in one iteration and the test step fails. This same test step though successful in the next iteration, is marked as failed.
Highlighted

Re: Scripted assertions in JDBC Requests - Issue

Hi,

I seem to have misunderstood your problem a bit at first. I've tried to reproduce the behavior you're mentioning, but to no avail (it works fine on my end). Is it possible for you to either give some steps to follow that showcase the error on your end, or attach a small project containing a setup that I can configure to reproduce it? That would help in tracking down the root cause.

Regards,
Arian
SmartBear Sweden

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️Please mark my answer as a solution if it was helpful
Highlighted
Occasional Contributor

Re: Scripted assertions in JDBC Requests - Issue

I have attached the project and the data source file. when run, the first iteration shall fail at JDBC_Request_HixGroupSetup_Initial sue to assertion failure. In the second iteration, though the assertions are successful, the same test step - JDBC_Request_HixGroupSetup_Initial shows as failed.
Highlighted
Occasional Contributor

Re: Scripted assertions in JDBC Requests - Issue

Pro Support Team,

Were you able to get to this? I am still waiting.
Highlighted

Re: Scripted assertions in JDBC Requests - Issue

Hi,

I downloaded the project, but as I don't have the same database access, there's no way to reproduce the issue on this end.

What happens if you run just the "JDBC_Request_HixGroupSetup_Initial" step? Does the assertion pass or fail when running the JDBC test step?

What happens when you open the "Script assertion" and click run (green play icon on top)? I see that you have a lot of log.info statements; do all of them show on the console?

Also, it looks like your code expects the value of 'expectedResult' to be only "True" or "False". But there's not else final catch statement.

Finally, I would recommend Test Case debugging to see exactly what the response is at runtime of the test case: http://www.soapui.org/Functional-Testin ... gging.html

Thanks,
Michael Giller
SmartBear Software

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️Please mark my answer as a solution if it was helpful
Highlighted
Occasional Contributor

Re: Scripted assertions in JDBC Requests - Issue

Iteration 1 : The assertion fails and the test step - JDBC_Request_HixGroupSetup_Initial is marked as failed. The logs after the failed assertion are skipped.
Iteration 2 : The assertion is successful. But still the test step JDBC_Request_HixGroupSetup_Initial is marked as failed. All the infos after the assertion logged. I am able to look up the results in the database too.

The generic behavior I observed is if a test step x fails in iteration n due to assertion failure, the same test step x fails in iteration n+1 even if the assertion is successful. the subsequent iterations are successful.
It seems like the test step result is cached and is returning the same result for the next iteration.

when I run the script assertion stand alone, it runs absolutely fine and all the infos are logged.

The 'expectedResult' is fed from the data source (Excel) and is always either "True" or "False".

I ran through the debugger and the response looks absolutely fine. I am getting the expected response from the SQL and the assertion passes. I can confirm that as the infos specified after the assertions are logged.
Highlighted
Occasional Contributor

Re: Scripted assertions in JDBC Requests - Issue

Any update on my issue?
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Check out this week's challenge!

Create a script to generate an email when an assertion fails for the TechCorner tag!


Scripts created in July:
- A script to change the request body before sending it to the server