t.Error and t.Fatal

The *testing.T methods that mark a test as failed: the Error forms continue running the test, the Fatal forms stop it immediately.

In more detail

Use t.Errorf for independent checks so one run reports every problem. Use t.Fatalf when later lines cannot make sense, such as when required setup failed or a result is nil. The f versions take a format string like Printf.

Example

t.Fatalf("double returned %d", got)

Related terms

Taught in

References