In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Wisdom RESTClient is a tool for automated testing of REST API, which can automate the testing of RESTful API and generate exquisite test reports, while generating exquisite RESTful API documents based on the tested historical API.
1. Preparation before using RESTClient 1.1 download RESTClient
JAR package: restclient.jar
1.2 install Java before use
Supported Java versions > = 1.7
1.3 start the RESTClient software
Double-click restclient.jar, or execute the command java-jar restclient.jar to start the RESTClient software.
The RESTClient main form contains:
Request View (Request) response View (Response) Historical View (History) menu bar (File, Edit, Test, Apidoc, Help) 2. Use RESTClient to test the REST API step 2.1 request view to enter the request data required by REST API
The details of the data entered for the tested REST API in the request view are as follows:
2.1.1 Select request method
The details of the RESTClient support request method are as follows:
Method name operation remarks GET query does not need to fill in the request body POST add PUT modify DELETE delete do not need to enter the request body 2.1.2 enter the URL to access the REST API
URL format: HTTP protocol: / / hostname: Port number / path
URL example: http://restclient.cn:8080/restapi2.1.3 input request body (Body)
You can enter the request body if the selected request method is POST or PUT, but not for other methods.
2.1.3.1 Select the request body type (Body-Type)
String (String)
Fill in the string directly in the text box of the request body
File (File)
Browse and select the text file, the contents of the file will be read and used as the request body.
2.1.3.2 Select a content type (Content-Type)
According to the body type of REST API message, compare the following table to select the content type that matches API. If none of the content types in the table are required by API, you can enter the desired type directly in the content type text box.
Details of common content types are as follows:
Content type (Content-Type) data format application/jsonJSONapplication/xmlXMLapplication/x-www-form-urlencodedForm form text/plain plain text text/xmlXML text text/htmlHTML text multipart/form-data is used to upload file application/xhtml+xmlXHTML2.1.4 selected character set (Charset)
The default character set is UTF-8. You can select the character set required by REST API. If none of the character sets in the drop-down list are required by API, you can enter the desired character set directly in the character set text box.
2.1.5 fill in the message header (Header)
You can add corresponding headers in the form of key-value pairs according to the requirements of the REST API definition.
Example of Header key-value pair:
Key: AcceptValue: application/json2.1.6 enter Cookie
According to the requirements of the REST API definition, you can add the corresponding Cookie in the form of key-value pairs.
If API needs login authentication, please first use the browser to complete the API login verification, and then fill in the JSESSIONID generated by the browser into Cookie, so that you can directly access REST API without login authentication, and do not need to log in to use the details.
Example of Cookie key-value pair:
Key: JSESSIONID Value: MY0REST1COOKIE2DEMO32.1.7 complete request data example
Clicking the Start button after filling in the request data will trigger the API request. Enter the complete request data in the request view as shown in the figure:
2.2 data returned from the REST API response in the response view
After the REST API request is completed, the response data is as follows:
Response status code (Status) response message body (Body) response message header (Header) raw response data (Raw)
The response data is shown in the figure:
2.3 record the tested REST API in the historical view
The visual edits you can make to API in the history view are as follows:
Refresh API to adjust the order of the selected API delete the selected API or empty all the historical API to edit the selected API
The shortcut menu for visual editing of history API is shown in the figure:
2.4 retest the historical REST API
If you need to retest the historical API, click Test = > Start Test in the RESTClient menu bar
After the recorded history API test is complete, the test report is opened using the default browser on the Windows system. Other systems can manually open the test report according to the report path in the prompt box.
The test report is shown in the figure:
2.5 generate API documents for historical REST API
If you need to generate API documents, click Apidoc = > Create in the RESTClient menu bar
After the API document is generated, the API document is opened using the default browser in the Windows system. Other systems can manually open the API document according to the document path in the prompt box.
The API document is shown in the figure:
2.6 Editing the historical REST API
To meet the API retest requirements or API document data requirements, you can do the following on API:
Adjust the API order to delete redundant and abandoned API for visual editing of API
Select API in the history view, and select Edit from the shortcut menu to open the API editing form, as shown in the figure:
In the API editing form, you can edit the following:
Request method request URL request header (Header) request body (Body) response status code (Status) response message body (Text view) whether to verify the returned message body (Assert Body)
If Assert Body,API is checked by default, the returned message body will be fully matched and checked. If you do not need to check the returned message body, you can check it.
If some JSON nodes in the returned message body do not need retest matching check, you can check exclude these nodes on the Viewer view, so that API retest only matches the nodes that are not excluded.
2.7 Custom API documents
If the generated API document does not meet the requirements and needs to be changed, you can modify the data file work/apidoc/js/apidata.js to customize the API document. For more information on API customization, please see Resources.
2.8.Automated testing of REST API using RESTClient via command line (CLI)
RESTClient supports launching and retesting API and generating API documentation by executing commands. See Resources for RESTClient CLI usage details.
Through the way of CLI, it is easy to execute commands regularly in Jenkins to schedule RESTClient for API retesting, thus automating the test REST API and generating REST API documents.
3. Question consultation and help
If you encounter problems while using RESTClient, you can check the RESTClient log file: work/log/rest-client.log, which makes it easy to find out the specific cause of the problem.
For more examples of using RESTClient, please refer to the relevant technical materials for more examples and help.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.