We have a requirement in our project to fetch an id from a REST end point and that would be stored in the DB.
We have to do this in Before Run event and we are using ProjectListener.beforerun event for it. I tried but not able to proceed further.Can some one please help me in implementing this, that is calling the REST end point (it is defined in a project in a separate testsuite) from the groovy script in BeforeRun event.
I can maintain the REST end point in the project or it is even ok to construct the end point and hit the service in the BeforeRun event groovy script.
So the final flow will be, first it comes to the BeforeRun event hits the end point and fetches the id and the same will be inserted as a record in DB and then BeforeSuite, BeforeTestCase, BeforeStep and the actual teststeps executions goes.
Project -> TestSuite ->TestCase ->RestEndpoint (to fetch the id)
Before the execution is triggered, I have to insert a record into the DB and for that I neeed an id and that I will get by hitting the above end point. Connecting to the DB and inserting the record and all that am able to do, but am not knowing how to hit the end point from the BeforeRun event. Thanks alot that your response has the details to fetch the rest end point in test suite-test case, can you please tell me, after reading the end point how it can be triggered. So that I will read the response and capture the id details and will set in a global property.
Then after the other execution continues, that is BeforeRun, BeforeTestSuite, BeforeTestCase and the steps in the testcase.
Even am ok, instead of maintaining a test case with end point to fetch id details , if I can create an end point in the BeforeRun Event and hit the service and read the id details,