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.
Related
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
I'm trying to parse the last received message from Pushbullet. I'm currently doing it using Clicks, which means that I do every single clicks, sendkeys and all the rest needed actions automatically. In other words it is just a simulation of the user. One of the biggest con of the method is that whenever xpath or a class or id of the element changes which I'm aiming with Selenium, whole cycle fails and the test case can not proceed operating.
I want to change the way I'm doing. Particularly, I want to send a json request to Pushbullet API and then get the response in return.
I just couldn't decide from where and how to start doing.
Could you guys please tell me the way from where should I start and what are the steps that needs to be covered in order to finally reach the finish line?
Thank you in advance.
I noticed that this question is tagged under Selenium, but in your question, you express interest in switching to an API approach. I will try to provide some advice to you on this.
Selenium Approach
You mention that you tests are brittle, and if anything changes then they fail. This is usually the case with UI tests. If you would like to stick with the Selenium approach, I can try to help you write more robust locators for your WebElements that will not break constantly.
API Approach
You will need to start with the Pushbullet API documentation -- https://docs.pushbullet.com/
To get messages, it looks like you will want to use the chat endpoint -- a sample request looks like this: https://api.pushbullet.com/v2/chats, plus authentication.
Once you fetch the chat objects, you will need to write your own logic to parse each chat object and fetch the most recent message from there.
Depending on what language you are using, you will need to install a REST client package onto your project. I use C#, so RestSharp is the client I like to use.
I recommend installing a REST client interface, such as Postman, to start practicing your API calls. Once you get your API calls working in Postman, you can start writing code to make these API calls.
What other questions do you have about this?
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.
As I said in the question, is it possible to pass jmeter variables (passed through -J) into a JUnit Request in order that it can be used internally to the junit test?
It sounds feasible as the Apache Junit Request docs indicate that:
... JMeter currently runs the test methods directly, rather than
leaving it to JUnit. ...
This would indicate that jmeter could control passing parameters but I've found no supporting documentation and there's no obvious mechanism through the JUnit Request sampler config.
Background
I was hoping to use CSV Data Set Config to load a user pool (as in Victor Klepikovskiy excellent top tips) and have a randomly obtained user provided to my unit-tests (for use across the thread/ loop). I've found an alternative way of doing what I want (but use my own user pool accessed from within the junit tests). I know you could manage the login through Http Request too (as above) but we amanage the rest-service calls internally to junit so that they can be run as junit tests as well. I was interested in being as non-intrusive as possible.
A second reason for doing so might be to have a single junit test method but have it parameterised to suit the scenario.
Addendum
For what it's worth, I'm happy with my current alternative approach but still interested in how you might be able to do this for future reference. I'm fairly new to jmeter but expect to see a fair bit more of it. Was also thinking of looking at the pre-processors but not sure how these could interface with the Junit Request.
I have tried to do exactly what you are doing (although, never specifically used -J).
The short answer is I have still not found a way to make it work to pass variables into a JUnit Request. I believe it is not currently supported.
At the time, the only way I saw of doing this was passing a parameter (e.g., ${__threadNum} or even from CSV Data Set Config) into the Constructor String Label and writing my constructor appropriately. However, I only got the string literal "${__threadNum}". I contacted support and they mentioned to me that this will not work. I forget exactly what they said and cannot find the email. But the main idea was that a JUnit Request is instantiated or created before the parameter in the Conostructor String Label is parsed. So that is why it will not work.
I am currently using the same alternative you are by having my test read credentials from a file.
I tested and it all works. what needs to be done is:
Source: blazemeter.com how-use-junit-jmeter
1) add the following jar files in the project libraries:
..\JMeter\apache-jmeter-3.0\lib\ext\ApacheJMeter_core.jar
..\JMeter\apache-jmeter-3.0\lib\ext\ApacheJMeter_junit.jar
2) in the class, add the reference to the sampler:
import org.apache.jmeter.protocol.java.sampler.JUnitSampler;
3) Add the code in the #Test tag to handle variables:
Click to see Code
4) Define variables in JMeter (both in user define variables and CSV)
Click to see JMeter Config
Hope it helps!
I need to know the easiest way to execute JSON in a selenium test. An example would be i want to POST { "UserId":"234234" } and test against what is returned. Currently using Advanced REST client chrome app to manually test. I've done a lot of searching on this topic but haven't come across any good examples.
This doesn't sound like it's best solved by selenium. With Selenium you would interact with the form to get that value to post, and handle the subsequent AJAX response / page refresh. If you wish to POST data you should look at a library that performs those types of operations across the wire.
If you are looking for a HTTP library, then Apache has a good one (Java based).