Sobes.tech
Junior — Middle

Can you tell about the testing process you used in your last project?

sobes.tech AI

Answer from AI

In my latest project in Go, I used unit testing with the testing package. I wrote separate tests for each key component, verifying the correctness of functions with different input data. I also used test tables for easier testing of multiple cases.

For integration testing, I ran tests that checked the interaction of several components together, such as working with a database through mock objects.

An example of a simple test:

func TestSum(t *testing.T) {
    tests := []struct {
        a, b, expected int
    }{
        {1, 2, 3},
        {5, 5, 10},
        {-1, 1, 0},
    }

    for _, tt := range tests {
        result := Sum(tt.a, tt.b)
        if result != tt.expected {
            t.Errorf("Sum(%d, %d) = %d; want %d", tt.a, tt.b, result, tt.expected)
        }
    }
}

I also used go test -cover to assess test coverage and CI/CD for automatic test execution upon commits.

Can you tell about the testing process you used in… - sobes.tech