Testing a REST API with GoConvey

huangapple go评论93阅读模式
英文:

Testing a REST API with GoConvey

问题

我正在编写一个简单的服务,并想知道如何使用GoConvey测试REST API端点。理想情况下,我认为我需要启动服务器来进行测试,但出于某种原因,我无法理解如何在Go中实现这一点。我在这个服务中使用原始的net/http堆栈和mgo数据库。有什么想法和帮助将非常受欢迎 Testing a REST API with GoConvey 谢谢!

英文:

I am writing a simple service and was wondering how should I approach testing the REST API Endpoints using GoConvey?

Ideally I believe I would have to launch my server to test it against, but for some reason I am not able to wrap my head around on how to do it with Go.

I am using the vanilla net/http stack for this service and mgo for the database.

Any idea and help would be very welcomed Testing a REST API with GoConvey

Thanks!

答案1

得分: 0

net/http/httptest 包对于创建一个特定的 http.Handler 服务器非常有用。

Andrew Gerrand 的测试讲座 从第 12 张幻灯片开始介绍了 httptest.Server 和 httptest.ResponseRecorder。

英文:

the net/http/httptest package is useful for creating a server for a specific http.Handler.

Andrew Gerrand's testing talk goes over the httptest.Server and httptest.ResponseRecorder starting slide 12

huangapple
  • 本文由 发表于 2016年4月12日 16:58:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/36568335.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定