Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 1000 Bytes

README.md

File metadata and controls

29 lines (19 loc) · 1000 Bytes

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.