integrations

apitest has many injection points which makes it very easy to integrate with other 3rd party tools and testing libraries.

Ginkgo

apitest accepts the *testing.T via an interface. This allows integration with other testing libraries such as Ginkgo. You can pass GinkgoT() which generates an object that mimics *testing.T and communicates to Ginkgo directly. See a full example here.

var _ = Describe("Ginkgo/Server", func() {

	var (
		t      GinkgoTInterface
		router *mux.Router
	)

	BeforeEach(func() {
		t = GinkgoT()
		router = server.NewApp().Router
	})

	Context("Successful CookieMatching", func() {
		It("cookies should be set correctly", func() {
			apitest.New().
				Handler(router).
				Get("/user/1234").
				Expect(t).
				Cookies(apitest.NewCookie("TomsFavouriteDrink").
					Value("Beer").
					Path("/")).
				Status(http.StatusOK).
				End()
		})
	})
})