Forum Discussion

asingh's avatar
asingh
New Contributor
12 years ago

How to use DataGen properties value within DataGen

Hi peeps,

I am trying to use a Datagen property within another Datagen property using Grovvy Script. But I am struggling. I do not have much knowledge on scripting.

I have a DataGen called DataGen TRXN which has properties as
QTY1 which is of Type Number and generates Random number
UP1 which is of Type Number and generates Random number
EV1 Which is of Type Script and should generate QTY1 * UP1

All I want is to extract the value of above properties and Multiply and generate EV1, So that the testcase can use QTY1, UP1 and EV1 concurrently.

I have used script as below

"def QTY1 = context.expand ('${Copy of DataGen TRXN#QTY1}')
def UP1 = context.expand ('${Copy of DataGen TRXN#UP1}')
EV1 = $($QTY1 * $UP1)"

Please help or suggest or enlighten me.

Thank you

Regards
Aalok

1 Reply

  • SiKing's avatar
    SiKing
    Community Expert
    First ... it is better to describe the problem you are trying to solve, rather than the broken solution you have.

    Second ... context.expand() returns a String. You might want to try something like
    def QTY1 = context.expand('${DataGen TRXN#QTY1}').toInteger()
    def UP1 = context.expand('${DataGen TRXN#UP1}').toInteger()
    EV1 = QTY1 * UP1