Forum Discussion

msalvador's avatar
msalvador
Frequent Contributor
3 years ago

property multirow

Hi guys,

I have a test case with:

1)request(REST Request)

2)data source(Verify Fattura)

3)assertion(assertion fattura)

 

In datasource, I run a query that extract more than one row, I set 2 properties cod_num_documento,imp_documento

 

I have to fetch properties results, and I use a groovy script, for the moment script below extract only one row, but I tried in different mode.

 


import groovy.json.*
import groovy.util.*
import java.util.logging.Logger

def username = testRunner.testCase.testSteps["Verify Fattura"].getPropertyValue( "cod_num_documento" ) //.ge testSuite.getPropertyValue( "cod_num_documento" )
def foo = context.expand( '${Verify Fattura#cod_num_documento}' )
//def a = ${Verify Fattura#cod_num_documento::1}
//Parse JSON content in the request
def cod_num_documento = context.expand('${Verify Fattura#cod_num_documento}[0]')
def imp_documento = context.expand('${Verify Fattura#imp_documento}')

4 Replies

  • richie's avatar
    richie
    Community Hero
    Hey msalvador,

    Can i ask, why bother with the groovy? If it's just to attribute values, why not use the embedded Datasource functionality and just move the 2nd rows content to the same row, but the 2nd column instead? Then you wont have to worry about groovy or iterating through and jumping to the next row....the embedded Datasource functionality does all the heavy lifting for you.

    Cheers,

    Rich
    • msalvador's avatar
      msalvador
      Frequent Contributor

      Could you please send a simple, I don't understand how to check values from a datasource

      • richie's avatar
        richie
        Community Hero
        Hey msalvador,

        Sorry in your first message you indicate you indicate the issue is youre using 2 rows of data, per request and your follow up message says you want a sample to show checking the datasource.....those are 2 different things.

        Do you just want an example project created with a payload that sources 2 values from a datasource file?

        Is that right?

        If "yes", can you publish an example payload and indicate which attributes need the values and i'll create a project with an example test case.

        Also....are you looping this testcase or is it a 1 to 1 ratio of testcase to testdata record? There was no mention of looping in your post and there wasnt any mention of looping/iterating in your groovy

        Cheers

        Rich