Last active
September 23, 2018 06:25
-
-
Save kuntao/531264f76b6f3ed4529e63460a97239f to your computer and use it in GitHub Desktop.
`go test` したいがtestifyの中でやってるType Assertで落ちる。これは適当に書いたコードで `main.go` の実装は空です。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println("Nothing Implemented") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "testing" | |
| "github.com/stretchr/testify/assert" | |
| ) | |
| type MyString string | |
| func TestMain(t *testing.T) { | |
| var expected, actual MyString | |
| expected = "expected string" | |
| actual = "actual stirng" | |
| // このassertで落ちる | |
| assert.Equal(t, expected, actual, "string doesn't match") | |
| // トレースを見ると | |
| // assert.Equal : https://github.com/stretchr/testify/blob/master/assert/assertions.go#L338 | |
| // assert.diff : https://github.com/stretchr/testify/blob/master/assert/assertions.go#L1352 | |
| // の流れでpanic | |
| } |
Author
kuntao
commented
Sep 23, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment