Recall & Review
beginner
What command runs tests in a Go module?
Use
go test in the terminal inside your module directory to run all tests.Click to reveal answer
beginner
How do you name a test function in Go?
Test functions start with
Test followed by a name, e.g., func TestAdd(t *testing.T).Click to reveal answer
beginner
What package must you import to write tests in Go?Import the <code>testing</code> package to use the <code>*testing.T</code> type and test helpers.Click to reveal answer
intermediate
How do you run a specific test function in Go?
Use
go test -run TestFunctionName to run only that test.Click to reveal answer
intermediate
What does
t.Fail() do in a Go test?It marks the test as failed but continues running the test function.
Click to reveal answer
Which file suffix is used for Go test files?
✗ Incorrect
Go test files must end with
_test.go to be recognized by go test.What argument type does a Go test function receive?
✗ Incorrect
Test functions receive a pointer to
testing.T to report test status.How do you skip a test in Go?
✗ Incorrect
Calling
t.Skip() skips the current test.Which command runs tests with verbose output?
✗ Incorrect
The
-v flag shows detailed test output.What happens if a test function calls
t.Fatal()?✗ Incorrect
t.Fatal() marks failure and stops the test function immediately.Explain how to write and run a basic test in Go.
Think about file naming, function signature, and command line usage.
You got /3 concepts.
Describe the difference between t.Fail() and t.Fatal() in Go tests.
Consider how the test function behaves after each call.
You got /2 concepts.