Sobes.tech
Junior — Middle

Milliseid testimisvahendeid või teeke olete oma töös kasutanud?

sobes.tech AI

Vastus AI-lt

When 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)
    }
}

Sometimes I also use benchmarks from the testing package to evaluate performance.