How Can I do performance testing using Rest Assured - rest

I am using rest assured to automate my project. In the same project, I want to do performance testing in the API. I want to know how can I achieve this task??

If you have existing set of tests and want to run them in multithreaded manner the options are in:
use ExecutorService to run them in parallel
"wrap" them into functions with JMH annotations
use a load testing tool capable of running JUnit tests (or whatever is your xUnit framework) like JUnit Sampler of Apache JMeter
However the above approaches will only allow you to kick off your tests in parallel and you won't be able to collect a lot of metrics like:
number of active threads
number of hits per seconds
response time
HTTP-protocol-based metrics like response code, connect time, latency
so it makes sense considering converting your restassured tests into "real" tests driven by the "normal" load testing tool, the majority of load testing tools provide record-and-replay capability by exposing a HTTP Proxy so if you run your restassured tests via this proxy the load testing tool will capture them and convert them into corresponding HTTP requests.

Related

Can we integrate the Rest Assured API Testing scripts with Jmeter?

Can we integrate the Rest Assured API Testing code with Jmeter?
I am planning to use Rest Assured for API testing but also want the same tests to carryout the performance testing with JMeter. Is there a way we can integrate the code created in testing Rest Assured with JMeter?
If current tests are developed using JUnit framework the easiest option is using JUnit Request sampler, just:
Drop the .jar with your tests under lib/junit folder of your JMeter installation
Drop rest assured jar and any other dependencies under JMeter Classpath
Add a JUnit Request sampler per test method
If your test design doesn't assume JUnit you can always record your rest assured tests using JMeter's HTTP(S) Test Script Recorder
Start JMeter HTTP(S) Test Script Recorder
Add this line to the beginning of your tests:
RestAssured.proxy = host("127.0.0.1").withPort(8888);
Start your tests normally
That's it, JMeter will capture the requests and store the relevant HTTP Request samplers under the Recording Controller

How to write Integration Tests for MEAN application

Currently, I'm creating a project that incorporates the MEAN stack, Docker, and Travis CI. I'm using Travis CI to automate builds for unit testing, integration testing, etc. I'm using Docker to help create a test environment. I've already successfully created unit tests thanks to resources via Medium. However, I haven't found many resources on writing integration tests for a MEAN application. I want to create tests to see if I get expected values in the Angular application when it connects to the REST API endpoints from Express, and the Express application is connected to a MongoDB server. Does anyone have any resources or advice on how to write these tests, and to execute them in a Dockerized test environment?
Having done something similar myself, just a piece of advice.
Test the services independently, like e2e tests for the api server, mail service for the frontend web app. If the selenium tests run alright with the webpage/app, and the api end point is on the local machine then everything looks to be working. There is nothing magic in docker. Your local configs should reflect what you're trying to test, and avoid overcomplicating things and write the testing yourself.
Tools often take more time to learn than the actual thing you're trying to acomplish if you do it yourself. Document it adequatly so the consumer of the container can replicate with minimal effort.
It's actually pretty hard, good luck.

Can gatling load test SQL database or MongoDB?

I need to make load testing on my persistent storages Postgres and MongoDB.
I'm wondering if it is possible to do with gatling? Because as I see gating supports only http and jms out of the box.
Unfortunately no, it was under discussion some time ago, however the functionality didn't appear to have high enough demand from the community hence it was discarded.
You can use Apache JMeter for database testing, it comes with MongoDB Script sampler for Mongo and JDBC Request sampler for any other databases which support JDBC protocol.
New JMeter tests and existing Gatling tests can be combined into a single test harness via i.e. Taurus tool which supports JMeter, Gatling and few more underlying load testing tools.

How can I get code coverage reports when testing REST API with TestNG?

I have a question that's very similar to what's discussed here:
Integration Test of REST APIs with Code Coverage
I deployed a war file that exposes the REST APIs to a web server and I'm using TestNG to write test cases for the REST APIs. I'm not unit testing - I'm only end-to-end / integration testing. Currently, I'm running test cases from eclipse in my machine.
My goal is to get coverage reports on the TestNG test cases.
Since the tests are local to my machine and the REST API is deployed in another server, EclEmma doesn't provide any meaningful data when I run the tests cases in my machine.
Is there a way to point EclEmma to the web server instead of my local machine and get the code coverage report?
Would it be better/possible to include the tests in the war file and run the tests from the web server? That should allow me to get the meaningful code coverage report, right?
The easiest way forward in cases like this is normally to start the web server inside of your IDE and run tests with coverage measuring in there. Even better to start the web server from within the tests - then a build tool like maven can also do code coverage reporting.

Automated REST testing tool for MAC

I'm currently using POSTMAN and Advanced Rest Client application to test my REST endpoints. These tool are great and make it very nice for testing. I am currently entering these calls manually and testing. However, I have a number of endpoints which have prerequisite calls that need to be made to handle their dependencies.
This is not a big deal, however if there is a way I can chain these calls to run in a certain flow waiting for the prerequisite to be completed before running the next I could harshness this to craft a fully automated API testing suite. Which, would give more flexibility rather than manually entering them.
Postman let's you do this using the Jetpacks upgrade. You can then use the recently released Newman tool to run them through the command line.