TutorialPedia.org
Toggle Menu
Home
Online Go Compiler
Tutorials
JavaScript Tutorials
Golang Tutorials
Linux Command Line Tutorials
Blog
All Posts
Go Testing and Benchmarking
Check your understanding of Go’s testing framework and benchmarking tools.
1. What is the required file name suffix for Go test files?
.test.go
_test.go
-test.go
.go_test
2. Which of the following types are used in Go testing and benchmarking?
*testing.T
*testing.B
*testing.M
*testing.P
3. Benchmark functions in Go must start with the prefix 'Benchmark'.
True
False
4. What is the base command to run tests in a Go package?
5. What is the required prefix for a test function in Go?
Test
TestFunc
GoTest
Verify
6. Which of the following methods can be used to indicate a test failure in Go?
t.Fail()
t.Errorf()
t.Skip()
t.Fatal()
7. The *testing.B type is used for writing unit tests.
True
False
8. What flag is passed to 'go test' to execute benchmark functions?
9. Which flag is used with 'go test' to run a specific test by name?
-test
-run
-specific
-name
10. Which methods of *testing.B are used to control benchmark timing?
StartTimer()
StopTimer()
ResetTimer()
Time()
Reset
Answered 0 of 0 — 0 correct