Forum Discussion

rupam_rajvanshi's avatar
rupam_rajvanshi
New Contributor
4 years ago

How to get pass/fail status of groovy scripting in excel sheet

Hello Everyone,

I am taking data from excel sheet for that I am using data source. I have written groovy script for asserting response. I want get status of groovy scripts status as pass or fail and I need to pass that status into the same excel sheet.

Please help me with solution

  • ChrisAdams's avatar
    ChrisAdams
    4 years ago

    Hi,

     

    I use one Groovy script per condition to test.  In my own main test suite, I have approx. 20 groovy scripts.

     

    I suppose you could return an array from your groovy script where each element is a condition test and then update your datasink step to reference the element of interest.  Not tried, but I imagine it's possible.  You could also return a JSON object from the Groovy script. E.g.

    [
        {
            "surname": "Scholes",
            "forename": "Paul",
            "surnameCheckResult": "PASS",
            "forenameCheckResult": "FAIL"
        }
    ]

    And then reference the values in the Datasink...  E.g.

    ${MyCheck#result.someConditionName}

    Again, not sure if this would work.

  • nmrao's avatar
    nmrao
    Champion Level 3
    In general, there are no explicit assertion be added to groovy script test step unlike other test steps.
    Of course one can have assertions with in groovy script, but one can't really find the status of groovy script test step and I doubt if there any API available.
    • rupam_rajvanshi's avatar
      rupam_rajvanshi
      New Contributor

      Is there any other way by which we can pass pass/fail depends on groovy script status to excel sheet?

       

      Regads

      Rupam

      • nmrao's avatar
        nmrao
        Champion Level 3
        I can suggest a test with default reporting.

        Create a project with a simple suite, add a test case and add the same script step and try generating report and see if you get the correct status.