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

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

Related

How Can I do performance testing using Rest Assured

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.

Azure - Use of dynamically generated Auth-token in Load Test requests

I'm quite new to Azure/AzureDevOps and its LoadTest app.
I need to execute a Load Test for a scenario where I login as a user and execute a few requests while logged in.
The original request is returning auth-token in its Response, that auth-token is used as one of the parameters for the Header in all other sequential Requests.
What I cannot figure out (nor find on the Internet) is to:
1. How to get the auth-token in the 1st Response;
2. How to use this token (dynamically) in all other Requests in the Load Test.
Any help is greatly appreciated.
I guess you intended to run a web test against your web application.
have you created your load test project with Visual Studio?
As for getting the auth-token and using it in other requests,I don't think it is achievable with azure devops load test app.
I believe it should be done in your web test code.
You can create your web test which introduced in this document or write your test in code with selenium or other tools. Add add the web test to a load test project. To deal with the dynamic parameters which cannot be detected by your web request in your test,you can check this document.
After you have created your load test project. You can upload your load test to azure devops load test shown as below pic.

Error in JMX file generated from Selenium IDE

I generated some JMX script from Selenium IDE using Jmeter Plugin for Selenium.
I could able to generate JMX file from IDE and try to run the same in Jmeter. I am getting Unknown host exception in Jmeter.
Do I need to make some special setting in Jmeter?
I don't have any idea what Jmeter Plugin for Selenium is so I would suggest reach out to this plugin developers.
In regards to converting Selenium tests into JMeter, you can just record the test while it is running in the IDE via JMeter's HTTP(S) Test Script Recorder.
Selenium IDE plugin should respect Firefox Proxy Settings so when you run your test in it JMeter will capture the relevant requests and store them in form of HTTP Request samplers.
Another option is using Taurus tool which has Proxy2JMX module allowing conversion of Selenium tests into JMeter .jmx test scripts, as a bonus you will get automatic correlation of dynamic parameters, it means you won't have to work them arround using post-processors, Taurus will do this for you. See How to Convert Selenium Scripts into the JMX Converter article for more details.

MQTT Load Testing via Jenkins using JMETER

I'm trying to run MQTT test using JMeter on Jenkins. I've integrated maven and used Github repository to run the script. The problem is when i try to run a simple API test, jenkins automatically creates a .jtl file(provided that i've added post build action) In case of MQTT test script, Jenkins Build is successful but the test fails showing this error " no JMeter files matching '*.jtl' have been found.". Why is it so???
Do you use Jenkins performance plugin? If not you should do it.
Do you run JMeter in the Non GUI mode? If not you have to.
In this article how to run JMeter with jenkins you'll find step by step guide for Jenkins configuration for launching JMeter tests.

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.