Forum Discussion

doubtsreadyapi's avatar
doubtsreadyapi
Contributor
5 years ago

Groovy Script for assertion to check whether the value is 0 or null in groovy script response

Hi 

 

I have executed the python script from readyAPi successfully, where as in response i get some value, i have to put an assertion, that value should not be 0 or null

 

the response when i run the python script using groovy in readyAPi is.

 

Wed Jun 17 23:48:09 EDT 2020: WARN: 44

 

Please let me know how this can be achieved. 

 

Thanks in Advance.

  • nmrao's avatar
    nmrao
    5 years ago
    You haven't followed what is suggested.
  • nmrao's avatar
    nmrao
    Champion Level 3
    Please show how the python script is run or the script which is being used.
    • doubtsreadyapi's avatar
      doubtsreadyapi
      Contributor

      nmrao 

       

      Below is the groovy script i am using to execute the python script from ReadyApi

       

      def table_count = ["python" , "C:/Pythonscripts/test.py", host,db_password,db_id]
      def process = new ProcessBuilder(table_count).redirectErrorStream(true).start()
      process.inputStream.eachLine {
      log.warn(it)
      }
      process.waitFor()
      return process.exitValue()

       

      In the groovy response i got 

       

      Thu Jun 18 03:20:19 EDT 2020: WARN: 44

       

      So i must put an assertion that 0 or null should not come in the response.  

       

      Thanks

      • nmrao's avatar
        nmrao
        Champion Level 3
        what is the value of "process.exitValue()"?
        Using that you can have the assertion.