Testing REST (GET) service that needs Excel and Database data sources
Hi,
I have a REST (GET) service that I am trying to test. This REST service needs a value that I have to obtain by running a query from my database.
Example of service:
https://${HOST}/RESTServices/api/test/${TEST_ID}
So I would need to query to get that ${TEST_ID}. I know this can be easily done by using a database data source, however, I also have Set Up Tests and Tear Down Tests within this Scenario that require me to use an Excel data source in order to obtain queries that will insert and delete my data as the test is executed.
So I have tried using both data sources at once, passing the excel one for the set up and tear down, and passing the database one to the actual service test but when I execute the whole Scenario, it fails at the set up tests saying that my database data source "contains no data" even though this set up test is not using that database data source. I also tried creating an aggregate data source but no luck.
Does anyone have any idea how I can make this work? Thank you.
Comments
-
Hi Diego,
There are a couple of consequential reasons as to why you may be experiencing no data. Currently, I only have an assumption of your use-case. Please verify.
- It seems as if you have a setup test which reads from the Excel Datasource and input data to your database.
- You run a SQL query to get a particular id from that database.
- You run a GET REST request using that id.
- You run a tear down test which removes all of the information from the database based on the Excel Datasource.
From the statement, "I know this can be easily done by using a database data source..." I am assuming that you were successful at using the Database Datasource. If not, please verify that this works using the database Datasource.
Rather than using the Database Datasource, why not try using the DB Tool instead of the Database Datasource as shown by the image below. After your setup test, the DB Tool can query for the data, and store it into an XML Data Bank. Your messaging client can grab the results from your XML Data Bank. The image below represents the setup I would use for the use-case above. Please let me know if this helps.2 -
This worked! I was able to retrieve the data I needed using the DB Tool and XML Data Bank which was then passed to my service test. Thank you!
1 -
Sounds good. You are welcome.
0