GO-vatar series: Basic Automation API with Golang
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.
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.
Get
Post
Put
Delete
Let’s draw up a scenario
Test Suite
Step Definitions
Run
Full Code
Basic is not about Hello, World!
only. ;p — MperMperPisang