How can we do functional testing with JMeter and integrate with Maven - html

I am trying to do API end points testing with JMeter. I am able to create test cases using JMeter GUI. But, facing while integrating JMeter with Maven Project. Please Help me.

There is no easy way to display the details of the failed requests, JMeter Maven Plugin is capable of only generating a HTML Reporting Dashboard which failures reporting capabilities are limited to:
The error table providing a summary of all errors and their proportion in the total requests
The Top 5 Errors by Sampler table providing for every Sampler (excluding Transaction Controller by default) the top 5 Errors :
So the options are in:
Modify the response message and add to it the information you need using i.e. JSR223 Listener
Use Flexible File Writer Listener to store request and response data and whatever else you need into a separate file
Amend the FreeMarker templates in the report-template folder according to your needs and configure JMeter to use this modified template folder for the dashboard generation
Any combination of all above

Related

dynamically update the request json and send it as multipart form data in karate [duplicate]

In my karate tests i need to write response id's to txt files (or any other file format such as JSON), was wondering if it has any capability to do this, I haven't seen otherwise in the documentation. In the case of no, is there a simple JavaScript function to do so?
Try the karate.write(value, filename) API but we don't encourage it. Also the file will be written only to the current "build" directory which will be target for Maven projects / stand-alone JAR.
value can be any data-type, and Karate will write the bytes (or plain-text) out. There is no built-in support for any other format.
Here is an example.
EDIT: for others coming across this answer in the future the right thing to do is:
don't write files in the first place, you never need to do this, and this question is typically asked by inexperienced folks who for some reason think that the only way to "save" a response before validation is to write it to a file. No, please don't waste your time - and please just match against the response. You can save it (or parts of it) to variables while you make other HTTP requests. And do not write your tests so that scenarios (or features) depend on other scenarios, this is a very bad practice. Also note that by default, Karate will dump all HTTP requests and responses in the log file (typically in target/karate.log) and also in the HTML report.
see if karate.write() works for you as per this answer
write a custom Java (or JS function that uses the JVM) to do what you want using Java interop
Also note that you can use karate.toCsv() to convert JSON into CSV if needed.
My justification for writing to a file is a different one. I am using karate explicitly to implement a mock. I want to expose an endpoint wherein the upstream system will send some basic data through json payload using POST/PUT method and karate will construct the subsequent payload file and stores it the specific folder, and this newly created payload file will be exposed through another GET call.

Performance testing - multiple websocket connections

I would need to test the "resistance" of the server receiving an increasing number of websocket connections, through which data is sent over MQTT.
To that purpose, I created a simple webpage which has an "onLoad" directive so that when it loads, it connects to the server over websocket and starts receiving the data. In order to simulate (and increase the number of websocket connections), I thought about JMeter with a Loop controller that opens the page. However, I note that when the page is loaded by JMeter, it does not establish the websocket (in other words, it discards the "onLoad") javascript directive in the page. Is there a special JMeter configuration I'm missing? Is there another way to achieved what I would like?
Many thanks - Christian
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
therefore your onload event is being absolutely ignored by JMeter's HTTP Request sampler as it doesn't execute any functions.
If you want to load test your websocket backend you will need to go for JMeter WebSocket Samplers and establish connection/send payload using the relevant samplers. The plugin can be installed using JMeter Plugins Manager, there are JMeter WebSocket Samplers - A Practical Guide article and some example JMeter scripts which you can use as the reference

Is there any way I can automate API testing in Postman?

Is there any way such that I can automate API testing in Postman?
I have a set of APIs and testing it manually takes a lot of time. It would be great if it is possible to give the input JSON in file so that it takes input from that file and test and give results whether its success or fail.
Thank you.
Yes, you can make use of the following:
Collection Runner
Monitors in Postman
Newman
Explanation:
With collection runner you can run a collection of your requests (API endpoints) all at one go and along with that you can write tests then it'll give you a result whether how many tests passed/failed.
There are more advanced things you can do with collection runner such as creating an infinite collection run with the use of postman.setNextRequest
You can make use of Postman Monitors which is basically your collection is ran in the cloud at a scheduled time (every day / as per the schedule you specify) and then monitor reports are shown which will basically give you the performance metrics and test reports of your APIs.
You can use Newman which is the command line tool and you can integrate it with your test pipeline / there are multiple ways in which people use newman. You can also generate HTML reports etc.
You can reach out to Postman Community for more help regarding this matter.
You can simply run Postman collections using newman.
newman run mycollection.json
For usage details check this link out.

Integration Server - save pipeline to database

I'm trying to create service, that writes input and output pipeline(xmldata) every time, that one of installed services is invoked. How my service should know, when other service is invoked? Is there any builtin tool to catch in&out pipeline and save to file or any other source?
You can use one of webMethods' build-in service in WmPublic package:
pub.flow:savePipelineToFile
Note that it's not recommended to use "savePipelineToFile" in production for obvious performance/resources reasons. And of course, to load the pipeline from the file use:
pub.flow:restorePipelineFromFile
The usual work flow to debugging in webMethods is:
Add the "savePipelineToFile" step as the first instruction in
your flow service.
Execute flow service or execute from some client that will trigger the flow service.
Disable the "savePipelineToFile" step in the flow service.
Add the "restorePipelineFromFile" step at the very top in your flow service.
Run webMethods Designer in Debug mode and step through. Once it
goes over the "restorePipelineFromFile" step, you should see the
entire content of the pipeline including the inputs as passed by the
client. If you continue stepping through your flow service step by
step then you should see the what the final output is.
The services "savePipelineToFile" and "restorePipelineFromFile" are very useful to debug your services. The "pipeline" file will be located at:
IntegrationServer\pipeline
If your requirements dictate that you need to produce xml flat files then use the following:
To serialize documents to xml (WmPublic package)
pub.xml:documentToXMLString
To write xml string to file (WmPublic package)
pub.file:stringToFile
Hope it helps!
EDIT:
By default the soap headers are hidden. Most of the time you don't need the soap headers but you can force webMethods to add the soap headers to the pipeline by doing the following.
1) Click on the web service descriptor.
2) In the properties panel, set "Pipeline Headers Enabled" to true.
The soap headers won't appear in your pipeline at design time. It will only exist at runtime. If you want to see the content of the soap header then you will need to use the "savePipelineToFile" / "restorePipelineFromFile" technique that I described previously.
To make the soap header appear at design time then you will have to do implicit mapping to the soap header fields as if they were there.

How to use JSON API without document

This might be a weird question but I am open for all the suggestions.
The background is I want to use script to automatically deploy/remove docker container on Jelastic, but unfortunately this part is not well documented in Jelastic official API document. Jelastic provided me a piece of sample code demonstrated how to use bash to create a new environment with a new docker container but it is not enough, I still don't know how to create/remove docker container by looking at the sample code.
Since Jelastic is using standard JSON API, I am wondering is there any tool which can automatically retrieve/detect that the parameters I can use with Jelastic JSON API?
If you were me, how would you get over this if there is no document as reference?
I am keen to use Jelastic, but this issue stopped me from onboarding, many thanks.
J.
All the parameters that can be used with Jelastic JSON API are specified at http://docs.jelastic.com/api/ page.
To use JSON API without document I suggests to you check the Postman API tool https://www.getpostman.com/. This application allows you to see all the sent/received data and allows you to passes JSON values without any document or any additional actions.
Simplest scenario for beginners: Go to API docs, section Users>Authorization, using Signin method you should to obtain the session value, that is necessary almost for all further actions. Then you need to obtain information about environment, section Environment>Environment, at first you should to executes GetEnvs method, then using the application identifier of the environment that was obtained from the previous command you should to executes GetEnvInfo method. As a results of the described scenario you will get all parameters and values that can be used with Jelastic JSON API for certain type of the environment.