Restful API Testing library written in Go - Feedback wanted!

xuanbao · · 875 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><a href="https://github.com/JonathonGore/api-check" rel="nofollow">https://github.com/JonathonGore/api-check</a></p> <p>I am working on a library for testing my api endpoints. It basically allows you to write simple JSON files that contain your expected ins and outs from your http endpoints, then asserts that they are correct. I am using it in one of my own projects and it makes testing my api endpoints end to end a lot easier.</p> <p>There is still a lot of changes and development needed to be done, but I would appreciate it if anyone had any initial feedback they could give me.</p> <hr/>**评论:**<br/><br/>dnephin: <pre><p>I would suggest looking at <a href="https://github.com/vcr/vcr" rel="nofollow">https://github.com/vcr/vcr</a> and <a href="https://github.com/kevin1024/vcrpy" rel="nofollow">https://github.com/kevin1024/vcrpy</a> which are very similar ideas implemented in other languages. Apparently there is also a go implementation (<a href="https://github.com/dnaeon/go-vcr" rel="nofollow">https://github.com/dnaeon/go-vcr</a>).</p> <p>Writing the JSON files out by hand works at the start when APIs are small, but it becomes very error prone as things change and APIs grow. Being able to automate it makes it a lot easier to use.</p> <p>You might also want to consider making it a test library that users can integrate into a <code>go test</code> suite. That way you don&#39;t have to implement all the parts that are already handled by <code>go test</code> and <code>testing</code>.</p> <p>Just my 2 cents, hope it helps!</p></pre>golang-api-check: <pre><p>Thanks for the feedback. Integrating it into go test is something I would like to do. </p> <p>I agree writing it out the tests for the entire api by hand would be a bit of a drag. I am considering maybe doing something with swagger docs, where I would automatically generate the test files by reading in the swagger file. I like this idea as it would keep testing consistent with your documentation (and maybe force you to write documentation).</p> <p>Thanks for the links as well, I haven&#39;t seen those before when.</p></pre>fharding: <pre><p>Shouldn&#39;t APIRequest and APIResponse&#39;s JSON fields be interface{} rather than map[string]interface{}? For example if an API endpoint just responds with <code>false</code>. Also I think you can replace assertJSON with reflect.DeepEqual.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

875 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传