Forum Discussion

lauravachon's avatar
lauravachon
Contributor
6 years ago
Solved

How can I include dependencies from an external jar file into a groovy script test step

Hello Community,

 

I am using the ready-api maven plugin. I have my dependency in the pom.xml. The depedency is being downloaded. My question is how can I use the classes in this jar file in a groovy test step.

 

I have tried using an import statement, but the script does not know where to locate the jar.

 

As a side note, we do not have admin rights on our local machines so I cannot install the jar file to the soapUi install directory. So, I need a way to tell SoapUi how to find the Jar file.

 

I pulled my code out into intelliJ and it works, but I cannot get it to work inside of soapUi.

 

5 Replies

  • This script will work for the sample provided and can be easily adapted.

     

    
    // get test response as json
    def json = new groovy.json.JsonSlurper().parseText(context.response)
    // build array of the result list, specifically the proceduresId element
    def array = json.result.list.proceduresId;
    
    // a quick test if an array is sorted is to compare it to its sorted self. 
    // FALSE means make a copy of the array and sort it, instead of sorting the original object
    assert (array == array.sort(false));