Tester en Go
Go possède un puissant package testing intégré. Pas besoin de bibliothèques externes comme JUnit ou PyTest.
Création d'un test :
Créez un fichier se terminant par _test.go.
go
func TestAdd(t *testing.T) {
got := Add(2, 2)
if got != 4 {
t.Errorf("attendu 4, obtenu %d", got)
}
}
Exécutez avec go test ./....