<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's blog)</p></pre>amaximciuc: <pre><p>I really like <a href="http://goconvey.co/" rel="nofollow">http://goconvey.co/</a> but it's the only library I used for testing(except the stdlib'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'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's just simple code you write and don't have to touch for a while. </p></pre>khaki0: <pre><p>Thanks, good advice.</p></pre>cfsalguero: <pre><p>I'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's the most documented for working with agouti (for end-end tests within a browser).</p></pre>flavasava: <pre><p>I'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>
