How to test one page in Go.
There might be better ways.
Hi, I’ve recently joined a company using Go. One day, I tried to test one page in Golang. For example, let’s say that there are three Go test pages such as A_test.go, B_test.go and C_test.go. Besides, each file refers to corresponding types like AAA, BBB and CCC in them. If you want to test only A_test.go, can you do ‘go test A_test.go’?
No we can’t
The test will show you an error like
undefined: AAA
What should we do to solve this error?
The solution
The solution is making the test read the file defining AAA like…
go test A.go A_test.go // A.go is defining AAA
However, it looks a little inconvenient for me… We have to make it read every file including types which are necessary for the test…