Retrieve values from Database in a list

Class library usage, coding and language questions.
symfony
Posts: 14
Joined: Tue Mar 11, 2014 9:19 am

Retrieve values from Database in a list

Post by symfony » Tue Mar 11, 2014 9:57 am

Hi there,
First, sorry if this question / information already exists, I didn't find it so far.
My problem is the following:
I want to retrieve values from a table in a database and store these values in a IList. In this way, I created a DataSource of type DB with a Query like this one: "Select Table.Field from Table". Then, I created a module variable in a script module and I assigned the DataSouce to the test case containing that script module. I noticed that my Test Suite runs OK, but it repeats the test case containing the script module as many times as the number of the records retrieved from database, each time for a different value. This scenario might be very useful in some circumstances but, in my case, I need the values from database to be retrieved in a list at once, in order to manipulate all the values in a single test case iteration. I tried to modify the type of the module variable mapped to the datasource from String (which is default) to IList<String> but it didn't worked throwing the well known "Cannot implicitly convert type 'System.Collections.Generic.IList<string>' to 'string' (CS0029)".
Does anyone have any idea how to do that?
Thank You

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Retrieve values from Database in a list

Post by Support Team » Mon Mar 17, 2014 1:39 pm

Hi,

I am afraid this is the way our data connector works. Each row of a column represents a test case iteration.
For more information about how the data driven testing works please see: Lesson 3: Data-Driven Testing.

When you want to save all the data in an IList you need to write your own code.
This shouldn't be a great deal since there is much information in the web about how to get specific information from a database.
If I can be of further help please let me know.

Regards,
Markus