<p>Generally when I write Go, I have a godoc server running so I can easily check the docs for the packages that I use (both mine and third parties). In addition I write many tests so I keep creating html coverages to see what parts I haven't covered yet.</p>
<p>While this is a very useful workflow, it's not very streamlined. For example, I have to refresh go coverage html report manually after each <code>go test</code> and even then the refresh make the view to jump to the first file in the file-list. Also I have to keep two windows open, one for docs and one for coverage.</p>
<p>So I was wondering if there's a tool that I can run in the root folder of my package and then it</p>
<ul>
<li>automatically discovers and run the tests for all of the sub-packages</li>
<li>creates and shows coverage reports</li>
<li>shows the docs for the package, sub-packages and all imported ones with the links to the source code</li>
</ul>
<p>So it would be kind of a local "CI"y tool. I looked around quite a bit and couldn't find anything that does the above. Is there such a tool available? </p>
<p>As a side note, have you found the need for such a tool? If not, what's your typical workflow? I'm curious to learn how to improve mine.</p>
<p>Thanks.</p>
<p><em>Edit 1</em> - In the title it should be "godoc", not "gocode".</p>
<hr/>**评论:**<br/><br/>dasacc22: <pre><p><a href="https://github.com/smartystreets/goconvey" rel="nofollow">https://github.com/smartystreets/goconvey</a></p>
<p>Runs tests on package and sub pkgs, does coverage. Not sure about the last bullet on your list.</p>
<p>You can ignore the whole new way to write tests with goconvey, it works fine with standard Go tests.</p></pre>khaki0: <pre><p>Ha. This looks pretty neat. I had seen goconvey but I was under the impression that I had to change my tests to use their BDD-style of test so I never gave it a try. </p></pre>mdwhatcott: <pre><p>Not true, there are two parts to goconvey, the BDD library (which is built on top of the "testing" package), and the runner, which actually just runs "go test" on all your packages when a change is detected.</p></pre>natefinch: <pre><p>Have you guys thought about breaking out the two pieces? They don't really seem to need to be together.</p></pre>mwholt: <pre><p>Yes, actually. <a href="https://docs.google.com/document/d/1R72jRHDdbadhn1TC9SXvZSccrWAphYpkjpVYklhLzdk" rel="nofollow">https://docs.google.com/document/d/1R72jRHDdbadhn1TC9SXvZSccrWAphYpkjpVYklhLzdk</a></p>
<p>Never got around to it, though - didn't have enough time.</p></pre>Growlizing: <pre><p>Goconvey is awesome. It runs all your tests, so if you want to avoid 'lock-in' to the their test syntax, you can write your tests with any go test compatible runner.</p></pre>bketelsen: <pre><p>+1 goconvey is awesome. BIG GREEN DASHBOARD</p></pre>johnnydoebk: <pre><blockquote>
<p>it works fine with standard Go tests</p>
</blockquote>
<p>It works incorrectly with some tests. Imagine you have the following function in your code:</p>
<pre><code>func SomeFunction(...) {
if condition {
panic("...")
}
}
</code></pre>
<p>In tests you want to make sure it panics in case of certain condition:</p>
<pre><code>func TestSomeFunction_PanicInCaseOfSmth(t *testing.T) {
// Make sure the function panic'ed.
defer func() {
if err := recover(); err == nil {
t.Error("SomeFunction was expected to panic, but it didn't.")
}
}
SomeFunction(...)
}
</code></pre>
<p>This is an absolutely valid test in go that should pass if <code>SomeFunction</code> panics. But, goconvey doesn't think so.</p></pre>dasacc22: <pre><p>I agree, this is a valid test. I haven't run into this in use of goconvey. File a bug report?</p></pre>johnnydoebk: <pre><p>They disabled GH issues and I don't feel like I want to send them e-mail.</p></pre>
Any tool that combines gocode + gocoverage in a web interface that can be run locally?
xuanbao · · 715 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传