gtest
4 分钟阅读
原文:https://pkg.go.dev/github.com/gogf/gf/v2@v2.6.4/test/gtest
Package gtest provides convenient test utilities for unit testing.
软件包 gtest 为单元测试提供了方便的测试实用程序。
常量
This section is empty.
变量
This section is empty.
函数
func Assert
|
|
Assert checks value
and expect
EQUAL.
断言检查 value
和 expect
EQUAL。
func AssertEQ
|
|
AssertEQ checks value
and expect
EQUAL, including their TYPES.
AssertEQ 检查 value
和 expect
EQUAL,包括它们的 TYPES。
func AssertGE
|
|
AssertGE checks value
is GREATER OR EQUAL THAN expect
. Notice that, only string, integer and float types can be compared by AssertGTE, others are invalid.
AssertGE 检查 value
大于或等于 expect
。请注意,AssertGTE 只能比较字符串、整数和浮点类型,其他类型无效。
func AssertGT
|
|
AssertGT checks value
is GREATER THAN expect
. Notice that, only string, integer and float types can be compared by AssertGT, others are invalid.
AssertGT 检查 value
大于 。 expect
请注意,AssertGT 只能比较字符串、整数和浮点类型,其他类型无效。
func AssertIN
|
|
AssertIN checks value
is IN expect
. The expect
should be a slice, but the value
can be a slice or a basic type variable. TODO map support. TODO: gconv.Strings(0) is not [0]
AssertIN 检查 value
为 IN expect
。应该是 expect
切片,但可以 value
是切片或基本类型变量。TODO地图支持。待办事项: gconv.Strings(0) 不是 [0]
func AssertLE
|
|
AssertLE checks value
is LESS OR EQUAL THAN expect
. Notice that, only string, integer and float types can be compared by AssertLTE, others are invalid.
AssertLE 检查 value
小于或等于 expect
。请注意,AssertLTE 只能比较字符串、整数和浮点类型,其他类型无效。
func AssertLT
|
|
AssertLT checks value
is LESS EQUAL THAN expect
. Notice that, only string, integer and float types can be compared by AssertLT, others are invalid.
AssertLT 检查 value
小于 expect
。请注意,AssertLT 只能比较字符串、整数和浮点类型,其他类型无效。
func AssertNE
|
|
AssertNE checks value
and expect
NOT EQUAL.
AssertNE 检查 value
和 expect
NOT EQUAL。
func AssertNI
|
|
AssertNI checks value
is NOT IN expect
. The expect
should be a slice, but the value
can be a slice or a basic type variable. TODO map support.
AssertNI 检查 value
不在 expect
。应该是 expect
切片,但可以 value
是切片或基本类型变量。TODO地图支持。
func AssertNQ
|
|
AssertNQ checks value
and expect
NOT EQUAL, including their TYPES.
AssertNQ 检查 value
和 expect
NOT EQUAL,包括它们的 TYPES。
func AssertNil
|
|
AssertNil asserts value
is nil.
AssertNil 断言 value
为 nil。
func C
|
|
C creates a unit testing case. The parameter t
is the pointer to testing.T of stdlib (*testing.T). The parameter f
is the closure function for unit testing case.
C 创建一个单元测试用例。该参数 t
是指向测试的指针。T 的 stdlib (*testing.该参数 f
是单元测试用例的闭包函数。
func DataContent <-2.0.5
|
|
DataContent retrieves and returns the file content for specified testdata path of current package
DataContent 检索并返回当前包的指定 testdata 路径的文件内容
func DataPath <-2.0.5
|
|
DataPath retrieves and returns the testdata path of current package, which is used for unit testing cases only. The optional parameter names
specifies the sub-folders/sub-files, which will be joined with current system separator and returned with the path.
DataPath 检索并返回当前包的 testdata 路径,该路径仅用于单元测试用例。optional 参数 names
指定子文件夹/子文件,这些子文件夹/子文件将与当前系统分隔符联接并与路径一起返回。
func Error
|
|
Error panics with given message
.
给定 message
的 .
func Fatal
|
|
Fatal prints message
to stderr and exit the process.
致命打印 message
到 stderr 并退出进程。
类型
type T
|
|
T is the testing unit case management object.
T为测试单元案例管理对象。
(*T) Assert
|
|
Assert checks value
and expect
EQUAL.
断言检查 value
和 expect
EQUAL。
(*T) AssertEQ
|
|
AssertEQ checks value
and expect
EQUAL, including their TYPES.
AssertEQ 检查 value
和 expect
EQUAL,包括它们的 TYPES。
(*T) AssertGE
|
|
AssertGE checks value
is GREATER OR EQUAL THAN expect
. Notice that, only string, integer and float types can be compared by AssertGTE, others are invalid.
AssertGE 检查 value
大于或等于 expect
。请注意,AssertGTE 只能比较字符串、整数和浮点类型,其他类型无效。
(*T) AssertGT
|
|
AssertGT checks value
is GREATER THAN expect
. Notice that, only string, integer and float types can be compared by AssertGT, others are invalid.
AssertGT 检查 value
大于 。 expect
请注意,AssertGT 只能比较字符串、整数和浮点类型,其他类型无效。
(*T) AssertIN
|
|
AssertIN checks value
is IN expect
. The expect
should be a slice, but the value
can be a slice or a basic type variable.
AssertIN 检查 value
为 IN expect
。应该是 expect
切片,但可以 value
是切片或基本类型变量。
(*T) AssertLE
|
|
AssertLE checks value
is LESS OR EQUAL THAN expect
. Notice that, only string, integer and float types can be compared by AssertLTE, others are invalid.
AssertLE 检查 value
小于或等于 expect
。请注意,AssertLTE 只能比较字符串、整数和浮点类型,其他类型无效。
(*T) AssertLT
|
|
AssertLT checks value
is LESS EQUAL THAN expect
. Notice that, only string, integer and float types can be compared by AssertLT, others are invalid.
AssertLT 检查 value
小于 expect
。请注意,AssertLT 只能比较字符串、整数和浮点类型,其他类型无效。
(*T) AssertNE
|
|
AssertNE checks value
and expect
NOT EQUAL.
AssertNE 检查 value
和 expect
NOT EQUAL。
(*T) AssertNI
|
|
AssertNI checks value
is NOT IN expect
. The expect
should be a slice, but the value
can be a slice or a basic type variable.
AssertNI 检查 value
不在 expect
。应该是 expect
切片,但可以 value
是切片或基本类型变量。
(*T) AssertNQ
|
|
AssertNQ checks value
and expect
NOT EQUAL, including their TYPES.
AssertNQ 检查 value
和 expect
NOT EQUAL,包括它们的 TYPES。
(*T) AssertNil
|
|
AssertNil asserts value
is nil.
AssertNil 断言 value
为 nil。
(*T) Error
|
|
Error panics with given message
.
给定 message
的 .
(*T) Fatal
|
|
Fatal prints message
to stderr and exit the process.
致命打印 message
到 stderr 并退出进程。