In Go 1.10 failfast flag is coming (hopefully) - Stops the tests after the first failing test

xuanbao · · 348 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I added a new feature to Go tests. In Go 1.10 (Jan 2018), we&#39;d be able to stop the tests after the first failing test.</p> <p>Like this:</p> <p><code>go test -failfast ...</code></p> <hr/>**评论:**<br/><br/>BeechM: <pre><p>Nice work. I&#39;m sort of surprised they allowed it, to be honest.</p></pre>hipone: <pre><p>What&#39;s the issue number?</p></pre>blackflicker: <pre><p><a href="https://github.com/golang/go/issues/21700">21700</a></p></pre>garblesnarky: <pre><p>What makes this so challenging that it&#39;s &#34;hopefully&#34; coming?</p></pre>blackflicker: <pre><p>It&#39;s been merged into the core. It&#39;ll probably be in Go 1.10.</p></pre>carutsu: <pre><p>Can we have sequential tests, though?</p></pre>blackflicker: <pre><p>Yes, you can.</p></pre>carutsu: <pre><p>In a very roundabout way, yes.</p></pre>blackflicker: <pre><p>You can run sequential tests with t.Run already since Go 1.7. And the new flag respects that too. Were you asking something else? </p> <p>Checkout: <a href="https://blog.golang.org/subtests" rel="nofollow">https://blog.golang.org/subtests</a></p></pre>carutsu: <pre><p>My bad. Odd, when I started to write tests I googled for something like this for a long time only to fail miserably. Thanks for pointing out I&#39;m mistaken. </p></pre>blackflicker: <pre><p>I&#39;m glad it helped.</p></pre>earthboundkid: <pre><p>It’s new in the last year or so. When did you look?</p></pre>carutsu: <pre><p>We started the project a little less than year ago or so. So i think i just failed on googling</p></pre>mcandre: <pre><p>Should be the default behavior.</p></pre>slewiskelly: <pre><p>Why? Encountering a test failure is no indication that subsequent tests will fail. At least you know exactly which test(s) are failing and which one(s) are not, at the end of test execution. </p> <p>I think the &#34;keep going&#34; approach is best; especially in table driven tests. I&#39;m super thankful of subtests for letting people write t.Fatal() without affecting subsequent tests. </p></pre>titpetric: <pre><p>True, same stands for other test suites like phpunit which has:</p> <pre><code> --stop-on-error Stop execution upon first error. </code></pre> <p>If you&#39;re (the reader of this comment, not parent) aiming for code coverage and the like, you&#39;d likely want to finish all tests, because the code coverage reports wouldn&#39;t be reliable anymore if you&#39;d stop the testing on the first error.</p></pre>XANi_: <pre><p>Most definitely should not</p></pre>

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

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