Ask Golang: do you do unit, module, AND systems tests and if not, why not? What's stopping you?

blov · · 431 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m keen to understand if and how people are doing unit, module, and system tests for their Go applications. I&#39;ve noticed the testing camp is split three ways: some people hate tests, some people don&#39;t get them or struggle with them, and some people love them. What are your thoughts? </p> <p>If you&#39;re somewhere in the middle, is it because you&#39;re unsure as to how to actually write the tests, what tools to use, how to make it easier, and so? What&#39;s stopping you from implementing them?</p> <p>All thoughts welcome.</p> <hr/>**评论:**<br/><br/>shovelpost: <pre><p>I consider testing to be a standard engineering practice. Go&#39;s tooling and culture make it abundantly clear that tests are part of the code. The <code>testing</code> package and <code>go test</code> make it trivial to write tests. In terms of test quantity for me it goes:</p> <p>unit tests &gt; integration tests &gt; e2e tests</p> <p>The testing tools we got are already pretty good and can help you go pretty far without even reaching for an external library which is the default in most other languages. I also think that Go is the only language that makes it easy to have runnable examples as part of the code which serve both as tests and documentation. </p> <p>Some useful resources:</p> <ul> <li><a href="https://golang.org/doc/code.html#Testing" rel="nofollow">https://golang.org/doc/code.html#Testing</a></li> <li><a href="https://golang.org/pkg/testing/" rel="nofollow">https://golang.org/pkg/testing/</a></li> <li><a href="https://blog.golang.org/cover" rel="nofollow">The cover story</a></li> <li><a href="https://talks.golang.org/2014/testing.slide#1" rel="nofollow">Andrew Gerrand - Testing Techniques</a></li> <li><a href="https://github.com/golang/go/wiki/TableDrivenTests" rel="nofollow">Table Driven Tests</a></li> <li><a href="https://www.youtube.com/watch?v=8hQG7QlcLBk" rel="nofollow">Mitchell Hashimoto - Advanced Testing with Go</a></li> </ul></pre>mikecrilly: <pre><p>Good talk. lol</p></pre>shovelpost: <pre><p>I visit the subreddit almost every day and I never saw this post until today. Given this is a new account, it&#39;s likely that your post wasn&#39;t approved yet by the moderators or something like that. After you make a post, you could try visiting the subreddit logged out to make sure your post it&#39;s visible.</p></pre>BACONWART: <pre><p>We write a lot of tests at my work place so it kind of comes to me quite naturally. That being said, I have yet to try out writing tests in Go since I am very new with the language. </p></pre>

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

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