Access TestSuite specific value in DataConnector

Class library usage, coding and language questions.
ThoMo
Posts: 5
Joined: Tue Mar 22, 2016 6:32 pm

Access TestSuite specific value in DataConnector

Post by ThoMo » Thu Mar 24, 2016 3:33 pm

Hi,

in my own DataConnector I want to load data depending on a test suite specific value. Also the value can be changed in one test case and the data connector should return values with respect to the new value.

Example:
TestSuite
TestCase 1
set x = 5
TestCase 2
DataConnector deliver: data[x] -> five
TestCase 3
set x = 2
TestCase 4
DataConnector deliver: data[x] -> two


How can access a value set in the test case in the DataConnector? I tried to use TestSuite.Current.Parameter but it doesn't work.

Regards,
ThoMo

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Access TestSuite specific value in DataConnector

Post by krstcs » Thu Mar 24, 2016 5:03 pm

First, please always include the following when asking questions:
1. Ranorex Version
2. Windows Version

These, along with any other pertinent information will make it easier and faster to help you.

In addition, what type of data connector are you using?

Ranorex Data Connectors are not strictly designed to be dynamic at runtime and instead are intended to be static.

Having said that, I use SQL Data Connectors in my tests and I just adjust the SQL Query immediately before the test case using dynamic values.

Code: Select all

((SqlDataConnector)DataSources.Get("<Your Data Cache Name>").Connector).Query = queryString;
dc.Load();
Doing this with a SQL Connector is pretty simple, but doing it with other types is not something I've really tried.
Shortcuts usually aren't...

ThoMo
Posts: 5
Joined: Tue Mar 22, 2016 6:32 pm

Re: Access TestSuite specific value in DataConnector

Post by ThoMo » Thu Mar 24, 2016 5:31 pm

Hi,
thanks for your suggestion. First my configuration:
  • Ranorex 5.4.0
    Win 7 (Dev), WinXP/Win2k/Win7 (Testexecution)
    My own DataConnector (Subclass of FileDataConnector)
Let me extend my example by some further notes.

Code: Select all

TestSuite (consists of 4 steps aka TestCases, all TCs are selected and executed)
  TestCase 1
     set i18n = 'en'
  TestCase 2
     inside the MyFileDataConnector: 
        get the current value of i18n
        load an language file specific to the value of i18n 
        return data depending on i18n, e.g. data[5] -> five
  TestCase 3
     set i18n = 'de'
  TestCase 4
     inside the MyFileDataConnector: 
        get the current value of i18n
        load an language file specific to the value of i18n 
        return data depending on i18n, e.g. data[5] -> fünf (german for five)
I have on solution using a singleton pattern (i18n is a static variable) but in this case the plugin and the Test project shares some code (the singleton). I wonder if there is a possibility to use some functionality/storage from the test suite or Ranorex core to pass values (the i18n value in my case) from the executed test to the data collector.

ThoMo

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Access TestSuite specific value in DataConnector

Post by krstcs » Thu Mar 24, 2016 6:26 pm

Creating your own data connector is not supported and uses an INTERNAL API that is subject to change at any time.

My understanding is that part of this API may be going away (being made private) or changing significantly in Ranorex 6.0.0, so you may not be able to do what you are trying anyway. You should probably look at doing this a different way.

My suggestion is to use a SQL Server (Express) database and have all of your data in the DB and just have 1 test case that loops over each set of language (i18n) data. This would be much easier than what you are trying to do here, from what I'm seeing.

Finally, you should update to a currently supported version of Ranorex (5.4.6 came out recently). 5.4.0 is pretty old and there have been numerous bug fixes and updates since then.

EDIT: My previous statement here was slightly misleading. To clarify: Ranorex Support only supports the last two MINOR versions, currently 5.3.X (.5) and 5.4.X (.6). Once 6.0.0 comes out, 5.3 support would likely end. It is still highly recommended to stay up-to-date with bug fix releases (the .X) because many issues are fixed in bug patches.

In addition, as Robert said in your other post about this API, internal APIs are not supported and are subject to removal (privatization) or change at any time, so you use them at your own risk (which means you really probably shouldn't use them).
Shortcuts usually aren't...