Forum Discussion

mrugglesaz's avatar
mrugglesaz
Occasional Contributor
12 years ago

Output JDBC Query & Results to Text File Using TestRunner

Smart Bears:

It would be great if the JDBC test step would output the query used and the results returned in the text output file that's created when executing test via the TestRunner. Currently, the JDBC test step only outputs a header with a timestamp (see attached output file); the query used and the results returned are not displayed in the output file anywhere.

I work for a company where saving testing artifacts is a must for auditing purposes. If the SQL query and results were output directly from my JDBC test step, it would save me extra screenshots and SQL query output files using SQL Server Mgmt Studio. I would rather do all my database manipulations/queries in SoapUI and be able to prove what I did in the TestRunner output files. Please consider parsing out the query that's used in the JDBC step and putting it in the request section of the output file and putting the query results in the response section (even in XML format if necessary). This would be a great time saver for me and my team.

Thanks,

Mark A. Ruggles

1 Reply

  • mrugglesaz's avatar
    mrugglesaz
    Occasional Contributor
    Forum Members:

    In case anyone is interested, the attached text file contains a Groovy script that gets the SQL Query & Results for any JDBC steps that are found in a test case and then appends them to the text file(s) that are output by executing the TestRunner. The script has worked for me in most cases. The only failure I've seen is in a test where I've set up a Conditional Wait using a Conditional Goto step along with a Delay step. Because of this design, the output of my final SQL query gets written to the wrong file, but that's only a minor bug with the script. Otherwise, this script will output your SQL Query & Results for tests with single or multiple iterations to the appropriate text files.

    FYI, in order to get the appropriate output directory to parse, I had to use an input box, which is displayed when the TestRunner executes. In order to see the input box displayed, you have to check the Enable UI feature on the Basic tab in the TestRunner popup window. The input box was the only way that I could find to get the same path as what is entered in the Root Folder field on the Reports tab in the TestRunner. I checked the API's and I can't find anything that let's me get the Root Folder value programmatically. This is the best design I could come up with. If anyone can improve upon it, feel free and let me know what you come up with.

    Thanks,

    Mark A. Ruggles