...
1[short] skip
2
3# Test
4go test -list=Test
5stdout TestSimple
6
7# Benchmark
8go test -list=Benchmark
9stdout BenchmarkSimple
10
11# Examples
12go test -list=Example
13stdout ExampleSimple
14stdout ExampleWithEmptyOutput
15
16-- go.mod --
17module m
18
19go 1.16
20-- bench_test.go --
21package testlist
22
23import (
24 "fmt"
25 "testing"
26)
27
28func BenchmarkSimplefunc(b *testing.B) {
29 b.StopTimer()
30 b.StartTimer()
31 for i := 0; i < b.N; i++ {
32 _ = fmt.Sprint("Test for bench")
33 }
34}
35-- example_test.go --
36package testlist
37
38import (
39 "fmt"
40)
41
42func ExampleSimple() {
43 fmt.Println("Test with Output.")
44
45 // Output: Test with Output.
46}
47
48func ExampleWithEmptyOutput() {
49 fmt.Println("")
50
51 // Output:
52}
53
54func ExampleNoOutput() {
55 _ = fmt.Sprint("Test with no output")
56}
57-- test_test.go --
58package testlist
59
60import (
61 "fmt"
62 "testing"
63)
64
65func TestSimple(t *testing.T) {
66 _ = fmt.Sprint("Test simple")
67}
View as plain text