Iterate through the Database Data Source
Hi,
I am current attempting to use a Database Data source to verify result returning from the web service. I've created a simple test suite that included a Database Data Source (DDS) and a simple test. This test would include a XML Transformer and XML Assertor. The DDS contains a simple SQL that return 1 column with 3 rows of data. Below is a sample returned XML and the value I am interested in verifying is RECORD_ID.:
Below is the DDS which should return 3 rows of data:
I've verified using SQL developer that the sql is correct and the database does contains the data that are needed
Below is the XML Assertor that I've created:
Unfortunately right now it does not seem to iterate through the Database Data source(DDS). The test fails because it continuously use the first row of value that returned from the DDS. right now, the test run and the first test pass as it verified 200613 matched but it would fail the other two tests as it would fail:****
Error Message:
DataSource: DB - Test 2 (2007-01-01, 1, 2006) (row 1): RECORD_IDs: For element "../RECORD_ID",
expected: 200613 but was: 200646
Error Message:
DataSource: DB - Test 2 (2007-01-01, 1, 2006) (row 1): RECORD_IDs: For element "../RECORD_ID",
expected: 200613 but was: 200642
Is there a way for me to see the returned values from the Database Data source (to ensure that it is actually contain 3 rows of data)?
Any advises or suggestions are much appreciated
Comments
-
Is there a way for me to see the returned values from the Database Data source (to ensure that it is actually contain 3 rows of data)?
In case this helps you, you could run a little groovy script from an Extension Tool to check the number of rows or the contents of a particular column:
import com.parasoft.api.* void checkDataSource(Object input, ScriptingContext context) { List<String> firstCol = context.getValues( "MyDS", // set this to the name of your data source "A") // set this to the name of some column in your data source Application.showMessage(Integer.toString(firstCol.size())) }
1 -
Hello @Lostwords,
Take look at the following post on how to verify service response values using a database data source: https://forums.parasoft.com/discussion/2984/how-to-assert-service-response-values-against-a-database
0