Hello, I am newbie to Go Lang and I am trying out writing test in Go.
Here is my test case written:
func TestLove(t *testing.T){
got := IkerTalk()
want := “Love is True”
if got != want {
t.Errorf(“got %q want %q”, got, want)
} else {
fmt.Println(“Damn”)
}
}
func TestHello(t *testing.T) {
got := IkerTalk()
want := “Hello Iker”
if got != want {
t.Errorf(“got %q want %q”, got, want)
}
}
When I click the green triangle in VSCode to run the test case,
Only running the test case itself:
Running tool: C:\Program Files\Go\bin\go.exe test -timeout 30s -run ^TestLove$ hello
=== RUN TestLove
Damn
— PASS: TestLove (0.00s)
PASS
ok hello (cached)
Directly run all test case throughout my whole directory with other test cases:
$ go test .
Damn
— FAIL: TestHello (0.00s)
hello_test.go:24: got “Love is True” want “Hello Iker”
FAIL
FAIL hello 1.282s
FAIL
The result outcome is that I will not have “PASS” result shown when running “go test” going through all the test case, but I did have “PASS” output when I am running it independently.
Is this expected? Or what should I do to see the “PASS” output when I go through all the test case with “go test” command?
Thanks in advance!!!