I was learning and exploring the popular open source frameworks, “REST-Assured” and “OkHttp”. An idea just popped into my mind, why not save the code on github so it would serve as a learning material for a beginner.
So, I created and posted the code which I wrote, on github in the following repository:
https://github.com/mfaisalkhatri/OkHttpRestAssuredExamples
While I was running the tests, I found an interesting thing which caught my attention. The execution speed of OkHttp when compared to Rest-assured was far better.
The following image shows the Test execution time which a Get Request took.
“2.002 seconds” was taken by OkHttp, however for executing the same API test using REST-assured, it took “3.131 seconds”. Similarly for running the next test, OkHttp took “0.124 seconds”, and REST-assured took “0.372 seconds”.
Now, lets jump to execution time taken for Post Request.
The following image shows the Test execution time which a Post Request took.
“2.252 seconds” was taken by OkHttp, however for executing the same API test using REST-assured, it took “4.521 seconds”. Similarly for running the next test, OkHttp took “0.649 seconds”, and REST-assured took “0.72 seconds”.
Going further, lets check execution time taken for Put Request.
The following image shows the Test execution time which a Put Request took.
“5.226 seconds” was taken by OkHttp, however for executing the same API test using REST-assured, it took “8.008 seconds”. Similarly for running the next test, OkHttp took “0.555 seconds”, and REST-assured took “0.77 seconds”.
Lets have a look at the Patch requests execution time.
The following image shows the Test execution time which a Patch Request took.
“2.171 seconds” was taken by OkHttp, however for executing the same API test using REST-assured, it took “4.268 seconds”. Similarly for running the next test, OkHttp took “0.623 seconds”, and REST-assured took “0.683 seconds”.
Lets have a look at the Delete requests execution time.
The following image shows the Test execution time which a Delete Request took.
“0.718 seconds” was taken by OkHttp, however for executing the same API test using REST-assured, it took “7.353 seconds”.
Considering the facts written above, we can say that OkHttp is faster and better in terms of execution than REST-assured.
However, in terms of writing the tests, I enjoyed writing the tests using REST-Assured as it has the method chaining feature which allows to write tests efficiently and in one go. However, that is not the case with OkHttp. (You can check the github link I have mentioned above to check how to write tests using REST-Assured and OkHttp).
To conclude, I would mention that it all depends on the automation framework you choose for your test project, in my view, you should choose the one which you feel implementing and maintaining is easy. As tests would be executed only once the implementation part is completed.