4

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.

Marit
  • 2,399
  • 18
  • 27
Dead Programmer
  • 123
  • 1
  • 5
  • 14

4 Answers4

12

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.

Marit
  • 2,399
  • 18
  • 27
  • 1
    Yes agree , We have same thing BDD as layer and in step definition we are calling rest assured. Try to use hamcrest assertion..that's perfect – N.. Jan 23 '18 at 21:51
  • Yes, hamcrest is really useful for assertions, especially as it given you information you need when assertions fail :) – Marit Jan 24 '18 at 10:11
1

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.

Filipe Freire
  • 823
  • 7
  • 21
0

Rest assured is java Api libraries to do automate REST web services. we can automated Rest apis by using BDD method,BDD is method and Cucumber is leading and free tool for that

Justin Lambert
  • 940
  • 1
  • 7
  • 13
-2

Rest assured is not a tool it is a java library which we can use for test restful webservices, and yes cucumber is recommended to use because customer is giving better reporting which rest assured is not supporting to reports.

So I can recommend use cucumber framework to test API