Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rest Assured vs Cucumber

I know what Rest Assured is and for what purpose it is used and the same for the cucumber.

But the thing is what we can achieve with Rest Assured, we can also do with Cucumber for testing.

Rest Assured simply calls the web service and validates the response. We can't use Rest Assured during the Maven build because the service needs to be up and running.

But with Cucumber I can directly call the web service's business service layer and DOA layer and validate the response. Cucumber can invoke this at Maven build time.

So question is which one is better? I know we can use/integrate Cucumber with Rest Assured but.

like image 822
Dead Programmer Avatar asked Dec 24 '22 10:12

Dead Programmer


2 Answers

Cucumber is a BDD tool and can be used to describe the expected behavior and use those descriptions as the basis for test automation. RestAsured is a tool to test API's/http calls. They do something different. You could use them both: Cucumber to describe you functionality, and RestAssured to do http calls.

like image 89
Marit Avatar answered Jan 05 '23 07:01

Marit


But with Cucumber i can directly call the web service's business service layer and doa layer and validate the response.

This is not necessarily true, and it has to do with the test level you want to achieve.

So if you just want to do tests on a unit level, then yes, you don't need to use REST assured, you can perfectly specify your tests with Cucumber feature files, and in the step definitions, you can test the service layer and the DOA layer directly, like you mentioned.

If you want to test a running instance of the webservice then you can use REST Assured or REST Assured plus Cucumber. REST Assured will only help you simplify the actual definition of each part of the test and the interactions with endpoints and its expectations, and Cucumber will allow you to define the high-level scenarios made of those steps.

So the question is which one is better? I knew we can use integrate cucumber with rest assured but.

All in all, it's not a matter of which one is better, but what level of testing you're trying to achieve and how you want to achieve it. A unit level you might not need REST assured. On an integration/live-execution level, then yes, you can use that library. In both levels, you can specify your tests using Cucumber.

like image 42
Filipe Freire Avatar answered Jan 05 '23 06:01

Filipe Freire