Back to course

Unit Testing: The Built-in way

Go (Golang) for Cloud-Native Microservices

Testing in Go

Go has a powerful testing package built-in. No need for external libraries like JUnit or PyTest.

Creating a Test:

Create a file ending in _test.go. go func TestAdd(t *testing.T) { got := Add(2, 2) if got != 4 { t.Errorf("expected 4, got %d", got) } }

Run with go test ./....