GO-vatar series: Basic Automation API with Golang

Ferawati Hartanti Pratiwi
2 min readAug 12, 2020

--

https://hackernoon.com/drafts/0fnv29qd.png

Hi! Back to the series which specifically discusses about Golang.

This time I’ll share about how to automate API. This is basic and I don’t want to complicated things, so check it out :D

Framework

Example

API

I will use https://crudcrud.com/ only for this tutorial. But you can also choose one of API in https://github.com/public-apis/public-apis. Remember that this API only have 4 methods (POST, GET, PUT and DELETE) and will expired after 1 day except if you’re willing to pay.

https://crudcrud.com/

Method

We will use only NewRequest method to hit the endpoint (https://golang.org/pkg/net/http/#NewRequest).

Constants

It’s like a variable group that we can use which contains a common method in HTTP.

https://golang.org/pkg/net/http/

Get

Post

Put

Delete

Let’s draw up a scenario

Scenario GET
Scenario POST
Scenario PUT
Scenario DELETE

Test Suite

Step Definitions

Hit endpoint
Validate endpoint response

Run

Full Code

--

--

Ferawati Hartanti Pratiwi
Ferawati Hartanti Pratiwi

Written by Ferawati Hartanti Pratiwi

Continuously striving to elevate QA standards with a quality-focused mindset

No responses yet