<p>I added a new feature to Go tests. In Go 1.10 (Jan 2018), we'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'm sort of surprised they allowed it, to be honest.</p></pre>hipone: <pre><p>What'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's "hopefully" coming?</p></pre>blackflicker: <pre><p>It's been merged into the core. It'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'm mistaken. </p></pre>blackflicker: <pre><p>I'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 "keep going" approach is best; especially in table driven tests. I'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're (the reader of this comment, not parent) aiming for code coverage and the like, you'd likely want to finish all tests, because the code coverage reports wouldn't be reliable anymore if you'd stop the testing on the first error.</p></pre>XANi_: <pre><p>Most definitely should not</p></pre>
In Go 1.10 failfast flag is coming (hopefully) - Stops the tests after the first failing test
xuanbao · · 348 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传