0
0
Goprogramming~5 mins

Running tests in Go - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A_testing.go
B.go
C_test.go
D.test
What argument type does a Go test function receive?
Astring
B*testing.T
Cint
Dbool
How do you skip a test in Go?
At.Fail()
Bt.Stop()
Creturn
Dt.Skip()
Which command runs tests with verbose output?
Ago test -v
Bgo test -run
Cgo test -fail
Dgo test -skip
What happens if a test function calls t.Fatal()?
ATest fails and stops immediately
BTest fails but continues
CTest passes
DTest is skipped
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.