Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/myriad-dreamin/mydrest
simple test helper
https://github.com/myriad-dreamin/mydrest
Last synced: about 1 month ago
JSON representation
simple test helper
- Host: GitHub
- URL: https://github.com/myriad-dreamin/mydrest
- Owner: Myriad-Dreamin
- Created: 2019-07-06T04:45:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-06T13:42:35.000Z (over 5 years ago)
- Last Synced: 2024-06-20T03:46:49.666Z (5 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Myriad-Dreamin's Test
使用方法
```go
package mtestimport "testing"
import qwq "github.com/Myriad-Dreamin/mydrest"type MyTestHelper struct {
qwq.TestHelper
}var s MyTestHelper
func TestA(t *testing.T) {
s.AssertEqual(t, 1, 1)
}func TestB(t *testing.T) {
defer func() {
if err := recover(); err != nil {
return
} else {
t.Error("does not fetch error...")
}
}()
s.AssertEqual(t, 1, 2)
}```
## Assertion
传入一个`testing.T`或者`testing.B`,即可开启Assertion
目前支持的方法:
#### `Assert(t, i, f)`
如果$f(i)$不成立,则向`t`报告失败,并panic
## `AssertEqual(t, a, b)`
如果$a=b$不成立,则向`t`报告失败,并panic
#### AssertNoErr(t, e)
如果`e`不为空,则向`t`报告错误,并panic
## CheckFunc
#### `IsNil(i)`
如果`i`为`nil`,则返回true,否则返回false
#### `IsNotNil(i)`
如果`i`不为`nil`,则返回true,否则返回false