Any third party testing library to make writing tests easier?

blov · · 902 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>The standard library <code>testing</code> package is very useful but writing tests can get pretty verbose quickly, full of <code>if</code>s. When looking for other testing libraries, I found these:</p> <p><a href="https://labix.org/gocheck">https://labix.org/gocheck</a></p> <p><a href="https://github.com/stretchr/testify">https://github.com/stretchr/testify</a></p> <p>Have you had any experience with these packages? Is there any other testing library that you recommend instead?</p> <hr/>**评论:**<br/><br/>nathj07: <pre><p>Also, you can reduce verbosity with table based tests.</p></pre>khaki0: <pre><p>Can you please clarify what you mean by table based tests? Like creating an <code>Eqaul</code> method for each struct and then testing it?</p> <p>edit: I found <a href="https://github.com/golang/go/wiki/TableDrivenTests" rel="nofollow">this</a>. I agree that it can reduce verbosity in certain cases.</p></pre>elithrar_: <pre><p>Also see <a href="http://dave.cheney.net/2013/06/09/writing-table-driven-tests-in-go" rel="nofollow">http://dave.cheney.net/2013/06/09/writing-table-driven-tests-in-go</a></p> <p>(in fact, just read everything on Dave&#39;s blog)</p></pre>amaximciuc: <pre><p>I really like <a href="http://goconvey.co/" rel="nofollow">http://goconvey.co/</a> but it&#39;s the only library I used for testing(except the stdlib&#39;s)</p></pre>nathj07: <pre><p>I tried gocheck but switched back to the standard lib. I found it tedious to learn a new dsl and framework for little benefit. I say all this coming from Java and Junit.</p></pre>dshills: <pre><p>I was using <a href="https://github.com/stretchr/testify" rel="nofollow">testify</a> but switched back to the std lib. I wanted to reduce dependencies and I found the std lib was often simpler to understand.</p></pre>space-llama: <pre><p>My company tried a bunch of testing packages and they were ok at best. One of the biggest problems was that they often got complicated with setups and tear downs and test suites and layers, etc. Once your tests became more complicated, deep-rooted bugs in the third party testing package would rear their heads. New DSL was also a huge barrier for new hires to start writing tests, which is a good habit to teach early. After a bunch of struggling, we just tossed it and settled on the one in the stdlib. It&#39;s incredibly powerful and straight forward. </p> <p>Table-driven tests greatly help reduce verbosity and can be found all over the Go codebase. Smaller, more directed, tests also help reduce the number of checks you need to do. In the end it&#39;s just simple code you write and don&#39;t have to touch for a while. </p></pre>khaki0: <pre><p>Thanks, good advice.</p></pre>cfsalguero: <pre><p>I&#39;m using gocheck and it has everything I need</p></pre>ande3577: <pre><p>I really like gocheck, but moved to gingko/gomega since it&#39;s the most documented for working with agouti (for end-end tests within a browser).</p></pre>flavasava: <pre><p>I&#39;ve been using testify for tests and benchmarks. No experience with other librarires, but I have no complaints</p></pre>pusic007: <pre><p>I am using httpcheck for integration testing. <a href="https://github.com/ivpusic/httpcheck" rel="nofollow">https://github.com/ivpusic/httpcheck</a></p></pre>

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

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