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.

Dump the contents of Writable Datasource to a file

Options
StaticAnalysis
StaticAnalysis Posts: 17

I would like to write the contents (in full) of a Writable Datasource to a file at the end of a test. What is the best way to achieve this? any code snippets (especially if using Jython) are appreciated.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,232 ✭✭✭
    edited March 2019
    Options

    I would like to write the contents (in full) of a Writable Datasource to a file at the end of a test

    What kind of file? CSV?

    What is the best way to achieve this?

    You would need to use scripting, like have an Extension Tool that runs at the end of your suite (maybe a tear down test) that reads the contents of the data source and writes out the values to a file in whatever way you desire. One of the arguments to the method in your script is of type com.parasoft.api.ScriptingContext. ScriptingContext has a method called "getValues" which takes "dataSourceName" and "columnName" as arguments. You can call this method on the ScriptingContext object multiple times to retrieve the contents of each column in the data source.

    any code snippets (especially if using Jython) are appreciated.

    Unfortunately, I don't have time to write sample code. However, if you are new to SOAtest scripting then I would recommend taking a look at Extensibility and Scripting Basics.

  • StaticAnalysis
    StaticAnalysis Posts: 17
    Options

    @benken_parasoft, Thank you for the feedback. I was exploring the extensiblility API last night and did not find an easy way short of retrieving data by the getValue method and then concatentating multiple gets as a string to retrieve row data. Is there a better way than this? I wish there was a method to getValues by ROWS also, as in my case, the data correlation between columns is important. API support for 'write to file' method as a part of teardown test would have have been awesome. Appreciate if this can be considered as a feature. Justification is to collect intermediate state data from one or more tests and report (and/or write to a file) on it at the end of the test.

    CSV or text file is fine with me. I'll test the teardown approach today.

    Thanks again.