Data Driven API Testing

Ask general questions here.
Posts: 16
Joined: Fri Apr 18, 2014 1:06 pm

Data Driven API Testing

Post by jaredmatthews » Fri Sep 26, 2014 5:43 pm

I need to test api calls against different data sources and assign the returned XML values to variables which I can then compare to each other.

For example:

DataSource 1

value a stored as $variableA

DataSource 2

value b stored as $variableB

then compare is (value a)=(value b)

I plan on doing this with user code as I think this is the only way. Is data binding possible with user code?

Anybody doing anything similar and can provide guidance?

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

Re: Data Driven API Testing

Post by krstcs » Fri Sep 26, 2014 6:41 pm

You can bind data in user code. Right-click anywhere in the user code region of the file and select "Insert Module Variable". Enter the name you want and a default value (will only be used if you don't bind a data source to it) and click OK. The trick is that Ranorex adds a .NET annotation to the property with a GUID. Ranorex picks that up when binding (this is the same way it does it internally for normal Recording Modules, btw) and binds that GUID to the data source.

You then just use that Module Variable however you want in your user-code just like you would any variable.

If you change the value, the new value is reflected in the data source IF THE SOURCE IS A PARAMETER (either global or test-case), but it will not change simple data tables, Excel, CSV, or SQL data results.

My suggestion would be that you do everything you need in one user-code method, read the two XML sets, compare everything, move on. Less to worry about. Keep it simple, which in this case means doing more code, from where I sit. :D
Shortcuts usually aren't...