Forum Discussion

ChrisA's avatar
ChrisA
Contributor
12 years ago

How can I ref datasource values in a test script assertion?

I want to be able to access the current datasource values in a script assertion of a REST Test Request.

Example: I have a simple web service to test that whether a name is registered as a valid user.

E.g. myServices/validUser?userName=John+Doe

I want to exercise the web service using an Excel data source....

USER VALID
==== =====
User1 TRUE
User2 TRUE
User3 FALSE
User4 TRUE


I have a simple test case setup for looping through the data source. E.g.
Datasource
Test Request
Datasource Loop

The request is geared up to use USER as a parameter. E.g. {DataSource#UserId}

In my test request, I want to be able to verify I get the expected response for each user. I thoughy script assertion would be best, but I can't figure out how to get the currently used (datasource) values in the script.

I want to be able to do soemthing like:

def user = context.expand( '$(DataSource#USER}' )
def valid = context.expand( '$(DataSource#VALID}' )

if valid
{
// do some assertion against valid user reponse
}
else
{
// do some assertion against invalid user reponse
}
No RepliesBe the first to reply