Skip to content

satorunooshie/e2e

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github.com/satorunooshie/e2e

Go Reference

Library for e2e and scenario testing.

Usage

Once a golden file generated by go test with golden flag, e2e compares HTTP status code and the response with the golden file.

Need at least only two lines, new request and run test, as below.

e2e testing only needs a minimum of two lines of code; one that creates an HTTP request and the other that executes the test.

t.Run(APITestName, func(t *testing.T) {
    r := e2e.NewRequest(http.MethodGet, endpoint, nil)
    e2e.RunTest(t, r, http.StatusOK, e2e.PrettyJSON)
})

For begin, run tests with -golden option to generate or update golden files.

go test -v ./... -golden

After updating golden files, run tests without -golden option to compare the responses.

For more detail, see examples.