<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'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't seen those before when.</p></pre>fharding: <pre><p>Shouldn't APIRequest and APIResponse'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>
