英文:
Testing a REST API with GoConvey
问题
我正在编写一个简单的服务,并想知道如何使用GoConvey测试REST API端点。理想情况下,我认为我需要启动服务器来进行测试,但出于某种原因,我无法理解如何在Go中实现这一点。我在这个服务中使用原始的net/http堆栈和mgo数据库。有什么想法和帮助将非常受欢迎 谢谢!
英文:
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
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论