如何在Go中避免重复的测试?

huangapple go评论70阅读模式
英文:

How to avoid duplicate tests in Go?

问题

由于Go语言在某些集成开发环境(IDE)中不允许调试测试代码(参见这个问题和这个问题),我不得不在我的队列实现中将测试代码写两次。

一次是在 main.go 中,第二次是在 queue_test.go 中。

我使用的是 Visual Studio Code 和 delve。

有没有什么最好的 IDE 或者模式可以在不重复编写测试代码的情况下调试 Go 语言的测试代码?

英文:

Since Go does not allow to debug tests in some IDEs (see also this issue) I had to write my tests twice in my queue implementation.

One time inside main.go, second time - inside queue_test.go

I use Visual Studio Code with delve.

What is the best IDE or pattern to debug Go tests without duplicating them ?

答案1

得分: 3

我认为你的IDE无法调试测试。

尝试一些不同的方法。例如,截至今天,Gogland的早期访问版本在调试方面表现得非常好,甚至可以调试测试。它在内部使用Delve调试器,所以你甚至可以从终端手动运行调试器,或者检查一下它是否已经与你选择的IDE进行了集成

英文:

I think your IDE is unable to debug tests.

Try something different. For example, as of today, the early access edition of Gogland works quite well with regards to debugging, even with tests. It uses the Delve debugger under the hood, so you can even resort to run the debugger manually from terminal or check to see if it is already integrated with your IDE of choice.

huangapple
  • 本文由 发表于 2017年3月22日 08:33:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/42940676.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定