678
6 years agoRegular Contributor
Reusable REST Requests
I have a scenarios where i need to call some Frequently use REST Requests in other test cases How can i setup this , i am using READYAPI
Hi,
Essentially "yes" is the answer to whether you would need a login request on each test case - that is - as long as there are session variables in the login response you need to pass onto your subsequent requests to enable the other requests to work?
How long does the 'session' (after logging in) last? 15minutes?
Is there a reason you couldn't create a login request in your first test case in your first testsuite, then grab the session variables from the login response passing them to a project property perhaps and then just use these session variables for your other apis you are testing for your other testsuite's testcases so you don't bother logging in for each test and logging out after every test?
If your 'session' lasts 15minutes - depending on your tests/network latency etc., etc. you could possibly only need to login once per execution run.
what I mean by this is the following hierarchy
TestSuite1
TestSuite1 TestCase1 'Login Request' (grab session variables and pass these variables into project or TestSuite1 properties) TestCase2 'Datasource' (fileContents property created) 'Search Request' (using the session variables via the project/TestSuite1 properties, grab values from response to pass to SearchID property) 'Properties' (contains the SearchID property from the Search Request) 'Purchase Request' (uses project properties, SearchID propoerty and the ${Datasource#fileContents})
and final TestCase's final step would be the 'Logout Request' to close the session etc.
Can you be a bit more specific about what you mean by "all the test case is coming from excel"? I'm not really understanding what you mean.
Are you saying the test cases have been defined in a spreadsheet?
Are you saying the test data for the requests for your tests are defined in a spreadsheet?
thanks,
richie
I am not only using Login and Logout i have other scenarios also where i need to call some rest request frequently as a pre-req
example ... create user, edit user, etc.,
Scenarios ; Testcase 1 : Step 1 (Login Rest Request)
Step 2 ( create user Rest Request)
Step 3 (do some validiations)
Step 4 (logout Rest Request)
Testcase 2: Step 1( Login Rest Request)
Step 2 ( create user Rest Request)
Step 3 (Do some validations )
Step 4 (logout Rest Request)
on the above scenarios login, create, logout are repeatable REST Requests... any help appreciated for solution
as per your suggestion i used run Testcase step but properties are not returning from that runtest case like i am grabing a token from login request (Runtestcase step) i checked return properties but properties are coming as empty