有誰知道如何打印例如結構的差異,以便 Intellij 理解它,特別是在測試中?例如,在 Java 中使用 Hamcrest 或 Mockito 時,如果斷言失敗,這些庫會以 Intellij 可以理解的方式打印,當您單擊斷言錯誤消息時,Intellij 會打開一個比較窗口,我可以很容易地看到差異有很好的突出顯示。有沒有支持這個的圖書館?
2 回答

飲歌長嘯
TA貢獻1951條經驗 獲得超3個贊
GoLand(或帶有 Go 插件的 IntelliJ IDEA)目前支持多個庫,點擊查看差異功能:
證明斷言 (github.com/stretchr/testify/assert)。
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestSomething(t *testing.T) {
assert.Equal(t, 1234, 123, "they should be equal")
}
去檢查(gopkg.in/check.v1)。
package main
import (
"testing"
. "gopkg.in/check.v1"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestHelloWorld(c *C) {
c.Assert(42, Equals, "42")
}
- 2 回答
- 0 關注
- 110 瀏覽
添加回答
舉報
0/150
提交
取消