Senior
Do you have experience writing unit tests and integration tests?
sobes.tech AI
Answer from AI
Yes, I have extensive experience writing both unit tests and integration tests in Go.
I write unit tests using the standard testing package to verify the correctness of individual functions and methods with various input data. This helps quickly identify errors at the module level.
Integration tests typically involve interactions between multiple components or with external services, such as databases or APIs. For this, I use test environments or mock services to check how parts of the system work together.
Here's an example of a simple unit test in Go:
func TestAdd(t *testing.T) {
result := Add(2, 3)
if result != 5 {
t.Errorf("expected 5, got %d", result)
}
}
This approach ensures code reliability and makes project maintenance easier.