Getting Started with the Automation API: Part 1 - Overview

 3r33434. 3r3-31. 3r33414.
Translation Article 3r3416. Shashi Kumar Raja
3r33417. 3r33412.  3r33434. 3r33414. So, let's say you want to do automation of the API, but every time you type
in the search bar in Google. best api automation tool
, you see so many references to dozens of top tools that you get confused and decide that you will definitely do this
tomorrow. 3r33417. 3r33412.  3r33434. 3r33414. Getting Started with the Automation API: Part 1 - Overview 3r31616. 3r33412.  3r33434. 3r33414. Let's start by understanding what we need if we want to customize (hopefully tomorrow) 3r333339. API automation platform
. Hold this thought for a second I said, stop thinking
I know that your boss doesn't give a penny for any paid tools
. Look, I read your thoughts, do not think out loud
3r33412.  3r33434. 3r33414. 3r33412.  3r33434.
3r33354. 1. where the hell should I start writing tests? 3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414. You will need something that will provide you with sets of rules and guidelines for writing tests, and also allow you to do this by giving you access to several tools and techniques. I hear the bell ringing, no !!! Well, I know what will make the bell ring. 3r33417. 3r33412.  3r33434. 3r33414.
Have you ever heard of 3r3358. TESTNG
, 3r360. JUNIT
, [leech=HTTP://MOCHA.ORG/] MOCHA [/leech] , [leech=HTTPS://DOCS.PYTEST.ORG/EN/LATEST/] PYTEST [/leech] , [leech=HTTP://ROBOTFRAMEWORK.ORG/] ROBOT [/leech] !? Yes, they are all test automation environments. 3r33333. 3r33417. 3r33412.  3r33434. 3r33414. You need to find a suitable testing environment based on your requirements: which existing technology stack does your company use? What automation do you want to do? Which language is more convenient for you, etc. You will find an automation environment in most popular languages ​​that will allow you to write
modular, functional and other
API test types. 3r33417. 3r33412.  3r33434. 3r33414. To learn more about the test environment, refer to the 2nd part of the series, where I introduced 3r3793 in detail. Mocha
and Pytest . 3r33417. 3r33412.  3r33434.
3r33354. 2. How am I going to make API calls in a test environment? 3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414. Most of these platforms support API calls, including the 333339 query library. HTTP request library
Because the REST API uses the HTTP protocol for communication. 3r33417. 3r33412.  3r33434. 3r33414. Some frameworks such as mocha , give you the freedom to use a library of HTTP requests of your choice, for example 3r3103. superagent
. 3r33417. 3r33412.  3r33434.
request
.post ('/api /pet')
.send ({name: 'Manny', species: 'cat'}) //sends a JSON post body
.set ('X-api-key', 'foobar')
.set ('accept', 'json')
.end ((err, res) => {3r3343429. //Calling the end function will send the request
}); 3r33434.

3r33412.  3r33434. 3r33414. They give you easy support for GET, PUT, POST, DELETE and all other methods. You can transfer headers, cache, request parameters, you called it - you got it 3r3417. 3r33412.  3r33434.
3r33354. 3. Cool, but some of my APIs give JSON, and others give XML in response, how can I deal with this? 3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414. Most of these HTTP request libraries will allow you to send and receive data in the format
JSON, XML, CSV, Text, Image, form-data, encoded-data
with several supported authorization standards. 3r33417. 3r33412.  3r33434. 3r33414. They also allow you to process the HTTP response status code and check whether we received the required response status code or not. 3r33417. 3r33412.  3r33434.
 3r33434. 3r3402. Informational Response Codes (1xx)
 3r33434. 100 - Continue
 3r33434. 101 - Switching Protocols
 3r33434. 102 - Processing 3r3405.  3r33434. 3r3407. 3r33412.  3r33434.
 3r33434. 3r3402. Success Response Codes (2xx)
 3r33434. 200 - OK 206 - Partial Content
 3r33434. 201 - Created 207 - Multi-status
 3r33434. 202 - Accepted 208 - Already Reported
 3r33434. 203 - Non-authoritative Info 226 - IM Used 3r33412.  3r33434. 204 - No Content 250 - Low Storage Space 3r33434.  3r33434. 205 - Reset Content
 3r33434. 3r3407. 3r33412.  3r33434.
 3r33434. 3r3402. Redirection Response Codes (3xx)
 3r33434. 300 - Multiple Choices 304 - Not Modified 3r33412.  3r33434. 301 - Moved Permanently 305 - Use Proxy
 3r33434. 302 - Found 307 - Temporary Redirect 3r33412.  3r33434. 303 - See Other 308 - Permanent Redirect
 3r33434. 3r3407. 3r33412.  3r33434.
 3r33434. 3r3402. Client Error Response Codes (4xx)
 3r33434. 400 - Multiple Choices 410 - Not Modified 3r3412.  3r33434. 401 - Moved Permanently 411 - Use Proxy
 3r33434. 402 - Found 412 - Temporary Redirect 3r33412.  3r33434. 403 - See Other 413 - Permanent Redirect
 3r33434. 404 - Multiple Choices 414 - Not Modified 3r3412.  3r33434. 405 - Moved Permanently 415 - Use Proxy
 3r33434. 406 - Found 416 - Temporary Redirect 3r33434.  3r33434. 407 - See Other 417 - Permanent Redirect
 3r33434. 408 - Found 418 - Temporary Redirect 3r33412.  3r33434. 409 - See Other
 3r33434. 3r3407. 3r33412.  3r33434.
 3r33434. 3r3402. Server Error Response Codes (5xx)
 3r33434. 500 - Internal Server Error 508 - Loop Detected 3r31234.  3r33434. 501 - Not Implemented 509 - Bandwidth Limited
 3r33434. 502 - Bad Gateway 510 - Not Extended 3r33412.  3r33434. 503 - Service Unavailable 511 - Network Auth Requried
 3r33434. 504 - Gateway Timeout 550 - Permission Denied
 3r33434. 505 - HTTP Ver Not Supported 551 - Option Not Supported
 3r33434. 506 - Variant Also Negotiates 598 - Nework Read Timeout Error
 3r33434. 507 - Insufficient Storage 599 - Network Connect Timeout Error
 3r33434. 3r3407. 3r33412.  3r33434.
3r33354. 4. Good, but how will I process the test data? 3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414. It depends on where you get the test data. These test frameworks allow you to use all the features of the language in which they are based -
3r33412.  3r33434. 3r33414. a.
Database:
You can easily create database connections to read data. 3r33417. 3r33412.  3r33434. 3r33414. b.
External file:
You can read external text, JSON, CSV or any other files. 3r33417. 3r33412.  3r33434. 3r33414. c.
Random dаta:
You can use libraries like faker , for generating random test data on the fly. 3r33417. 3r33412.  3r33434.
var faker = require ('faker'); 3r33434. 3r33434. var randomName = faker.name.findName (); //Rowan Nikolaus
var randomEmail = faker.internet.email (); //[email protected]
var randomCard = faker.helpers.createCard (); //random contact card containing many properties
3r33414. d. Data from the API response: Many times during testing you will need to send the response of one API as request data to another. You can do this using hooks .You will get features like Before, Before each, After, After each , which, as the name implies, is performed before /after any or all tests. Call API1 before API? and pass its response to API2. Just to the right !!! ️ 3r33417. 3r33412.  3r33434.
3r33354. 5. Processing the test data and executing the API calls seems simple, but how am I going to check the API responses? 3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414. To check the answers you need a library called 3r33339. Assertion library . Many test environments come bundled with assertion libraries, which gives you the opportunity to write asserts in plain English, such as syntax. They also allow you to check 3r3308. JSON schema your answer. 3r33417. 3r33412.  3r33434. 3r33414. In mocha, you can use any library of statements, for example, chai 3r31616. . 3r33417. 3r33412.  3r33434.
    response.status.should.equal (200)
foo.should.be.a ('string'); 3r33434. foo.should.have.lengthOf (3); 3r33434. tea.should.have.property ('flavors')
.with.lengthOf (3); 3r33434.

3r33354. 6. Fabulous !!! There was a trifle, after all this testing, to somehow show my boss what I did and where I found problems? 3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414. Most of these frameworks will provide you with 3r333339. basic HTML report
about the test run, which you can download and share. If you need more beautiful reports with graphs and charts, you can use several open source reporting tools, such as 3r33341. allure
or mochawesome . 3r33417. 3r33412.  3r33434. 3r33414. 3r33354.
7. Only if I could get some kind of template with these things to start automating the API now
3r33357. 3r33412.  3r33434. 3r33360. 3r33412.  3r33434. 3r33414.
What I told you, you called it, you got 3r33333. 3r33417. 3r33412.  3r33434. 3r33414. This is the template that I created for automate the API using mocha in node.js . 3r33417. 3r33412.  3r33434. 3r33414. It includes
3r33412.  3r33434.
 3r33434. 3r3402. Test-framework (mocha),
 3r33434. 3r3402. HTTP request library (supertest), 3r3405.  3r33434. 3r3402. Assertion library (chai),
 3r33434. 3r3402. Reporter (allure), 3r3405.  3r33434. 3r3402. logger (winston), 3r3405.  3r33434. 3r3402. Random data generator (faker), 3r3405.  3r33434. 3r3402. Eslint support and
 3r33434. 3r3402. 3r3403. naughty string validation integrated
. All you need to do is clone /download it and you are ready to go. 3r3405.  3r33434. 3r3407. 3r33412.  3r33434. 3r33414. If you need a template in another language, I can prepare it for tomorrow. 3r33417. 3r33412.  3r33434. 3r33414. If you liked this article you can clap your hands , it might encourage me to write more
3r33434. 3r33434. 3r33434. 3r33434. 3r33434. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r33434. 3r33434. 3r33434. 3r33434. 3r33434. 3r33434. 3r33434.
+ 0 -

Comments 13

Offline
Rank Feed
Rank Feed 13 July 2019 15:17
Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though.pname com facebook orca



Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.pname com facebook orca

Offline
booty pop panties
booty pop panties 14 July 2019 11:33
I really like this product!!! it was simple to use. the scent was smooth and subtle. it was not also fried and simply absorbed by my skin. it took a little time before I saw any results, but once I did, I was very happy using what I saw and obtained lots of compliments!!! I am really at a reduction for words at how happy I am and was to use that booty pop panties
Offline
Rank Feed
Rank Feed 16 July 2019 10:52
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.pname com facebook orca

Offline
Rank Feed
Rank Feed 16 July 2019 11:14
I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.pname com facebook orca

Offline
sohail khatri
sohail khatri 24 July 2019 13:32
I read a article under the same title some time ago, but this articles quality is much, much better. How you do this..Yoga For Lower Back Pain Relief



I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.Functional Strength Power Yoga Workout

Offline
sohail khatri
sohail khatri 31 July 2019 12:42
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.MPU Seminar




I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.MPU Gutachten

Offline
sohail khatri
sohail khatri 31 July 2019 20:27
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.Brazzers video - 1BRAZZERS



This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.먹튀

Offline
ASD
ASD 1 August 2019 13:38
Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign.Brazzers video - 1Porn

Offline
sohail khatri
sohail khatri 3 August 2019 09:41
This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post! Hiit Cardio Benefits for Weight Loss



This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work!Look Like A Dancer Yoga Workout

Offline
sohail khatri
sohail khatri 4 August 2019 14:35
You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant!Cardio Strength Training

Offline
sohail khatri
sohail khatri 6 August 2019 10:38
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.Electrolyte Requirements

Offline
sohail khatri
sohail khatri 8 August 2019 21:51
I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.How To deselect In Photoshop

Offline
sohail khatri
sohail khatri 15 August 2019 17:16
Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home.hacked website recovery

Add comment