Forum Discussion

chikki's avatar
chikki
Contributor
16 years ago

What is wrong here

Hi,

i am new bee.

I worked with (QTP) VB scripts earlier and very new new to Groovy/java and Soap UI.

i want to verify the list(a) contents with blist(b)

can i know what is wrong here

int k=0
for(k=0;k<=items.length;k++)
{
for(int m=0;m{
if (items[k]=u.EXTERNAL_ORG_UNIT_UID[m])
{
log.info("Response value ="+items[k]+ "and Db value="+u.EXTERNAL_ORG_UNIT_UID[m]+"matches")
}
else{log.info("Did not matched")}
}
}

your help is appreciated.

Regards,
Chikki
  • Hi chikki,

    Let me re-suggest you that you post to pro forums if you own a pro license.

    If you're comparing two arrays in Groovy/Java there's no need for nested loops. That actually applies to any reasonably modern (< 25 years old) programming language, incl. VB. What's more, being quite a very modern script language, Groovy makes list comparison ridiculously simple:

    a == b  ?  "Lists are equal" : "Lists differ"


    Groovy overrides other operators as well so you can do cool stuff like this:

    if (receivedResults == expectedResults) {
        log.info("All received results are correct, i.e. as expected.")
    } else {
        log.warn("Received unexpected results: " + ( expectedResults - receivedResults) )
        log.warn("Missing expected results: " + (receivedResults - expectedResults) )
    }


    Further references and tutorials on using Groovy language you can find in the Getting Started on the official Groovy website.

    I hope that helps.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla