【发布时间】:2017-08-15 05:24:11
【问题描述】:
我想在函数中使用断言,但它不是测试函数。这只是一个普通的功能,我想使用assert.Equal(param1, some_constant)之类的东西。我遇到了以下包:https://godoc.org/github.com/stretchr/testify/assert
不过,它似乎还需要testing 包,并为函数提供*testing.T 类型的参数。 Go 中有没有其他的 assert 函数,我可以直接调用 assert 函数而不实际依赖任何其他测试包或参数?
【问题讨论】:
-
如果你真的想要这个:为什么不写你自己的断言函数呢?为什么要依赖外部包?