Forum Discussion

Emil91's avatar
Emil91
Contributor
7 years ago
Solved

Data Gen - need help

Hello guys,

 

I need help, I'm new with new features in  soapUI NG pro, before i used to do tests in soapUI and I can't figure out how to generate random data..

Lets say i put some sort of data to excel file, and I would like to randomize such data so every request will be different..

The data types I'm interested in are: String, Int, Bool.

Thanks in advance for any kind of help, would be nice if I will finally figure it out, cheers!

 

best regards

Emil

 

 

 

  • There a few different ways of doing this. I typically use a custom groovy script I write to generate data to match my schema constraints, or use a groovy DataSource depending on how much data I need and the memory limitations of creating all of it up front.  There's also a data-gen step that can do the same thing.

     

    Datagen step

    groovy DataSource

     

  • You can do generate random data by using data gen test step, for say you need to pass random unique date ,

     

    1. Open Data Gen test step,

    2. Add property by clicking on + icon by giving desired name

    3. Select Type as Script

    4. Write groovy script to generate date under Configuration,

     

    def gc = new java.util.GregorianCalendar()
    def df  =  javax.xml.datatype.DatatypeFactory.newInstance()
    def datexml = df.newXMLGregorianCalendar(gc).toXMLFormat()
    return datexml

     

    Note: Make sure data Gen test step will be the first step under test case.

  • nagarajwst's avatar
    nagarajwst
    7 years ago

    If you want to pass the Numbers(int) select type as Number and give your required numbers as Start & End.

4 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    There a few different ways of doing this. I typically use a custom groovy script I write to generate data to match my schema constraints, or use a groovy DataSource depending on how much data I need and the memory limitations of creating all of it up front.  There's also a data-gen step that can do the same thing.

     

    Datagen step

    groovy DataSource

     

    • nagarajwst's avatar
      nagarajwst
      Occasional Contributor

      You can do generate random data by using data gen test step, for say you need to pass random unique date ,

       

      1. Open Data Gen test step,

      2. Add property by clicking on + icon by giving desired name

      3. Select Type as Script

      4. Write groovy script to generate date under Configuration,

       

      def gc = new java.util.GregorianCalendar()
      def df  =  javax.xml.datatype.DatatypeFactory.newInstance()
      def datexml = df.newXMLGregorianCalendar(gc).toXMLFormat()
      return datexml

       

      Note: Make sure data Gen test step will be the first step under test case.

      • nagarajwst's avatar
        nagarajwst
        Occasional Contributor

        If you want to pass the Numbers(int) select type as Number and give your required numbers as Start & End.