Junior — Middle
What testing tools or libraries have you used in your work?
sobes.tech AI
Answer from AI
In working with Go, I often use the standard testing package for writing unit tests. It is simple and integrated into the language, which is convenient for basic testing.
For more complex cases, I use libraries:
testify— provides convenient assertion functions and mock objects.gomock— for creating mocks of interfaces.httptest— for testing HTTP servers and clients.
An example of a simple test using testing:
func TestSum(t *testing.T) {
result := Sum(2, 3)
if result != 5 {
t.Errorf("Expected 5, got %d", result)
}
}
I also sometimes use benchmarks from the testing package to evaluate performance.