Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Scripting: How to write to datasource?

draven23
draven23 Posts: 5

I'm sure it must be possible to write to a Writeable Datasource from a script. I just haven't figured out how to do it.

This is my script:

import com.parasoft.api.*

String setRequestId(ScriptingContext context) {

    String orderId = '023' + new Date().format('yyyyMMdd')
    int productId = Math.abs(new Random().nextInt() % 999999999)
    String requestId = orderId + '00' + productId

    return requestId

    }

How do I write requestId out to a data source?

Thanks!

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    I'm sure it must be possible to write to a Writeable Datasource from a script. I just haven't figured out how to do it.

    There is no public API to do this. You must use a Data Bank. However, you can chain a Data Bank to an Extension Tool if you need a script to return the document needed as input to the Data Bank.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited October 2017

    Please also be aware that SOAtest 9.10.2 and later has a Data Generator tool. It acts very much like a Data Bank except can auto generate values (no scripting required). I think this is a better fit for what you are trying to do.

  • Shailaja_DS
    Shailaja_DS Posts: 1

    Hello People, Im new to parasoft tool, can anyone please tell me why do we use writeable datasource in a script testing.

  • jakubiak
    jakubiak Posts: 795 admin

    Writeable data sources are used when you need to capture data from one test that should be iterated over in a subsequent test.