OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // The testing package provides support for automated testing of Go packages. | 5 // The testing package provides support for automated testing of Go packages. |
6 // It is intended to be used in concert with the ``gotest'' utility, which autom
ates | 6 // It is intended to be used in concert with the ``gotest'' utility, which autom
ates |
7 // execution of any function of the form | 7 // execution of any function of the form |
8 // func TestXxx(*testing.T) | 8 // func TestXxx(*testing.T) |
9 // where Xxx can by any alphanumeric string (but the first letter must not be in | 9 // where Xxx can be any alphanumeric string (but the first letter must not be in |
10 // [a-z]) and serves to identify the test routine. | 10 // [a-z]) and serves to identify the test routine. |
11 // These TestXxx routines should be declared within the package they are testing
. | 11 // These TestXxx routines should be declared within the package they are testing
. |
12 // | 12 // |
13 // Functions of the form | 13 // Functions of the form |
14 // func BenchmarkXxx(*testing.B) | 14 // func BenchmarkXxx(*testing.B) |
15 // are considered benchmarks, and are executed by gotest when the -benchmarks | 15 // are considered benchmarks, and are executed by gotest when the -benchmarks |
16 // flag is provided. | 16 // flag is provided. |
17 // | 17 // |
18 // A sample benchmark function looks like this: | 18 // A sample benchmark function looks like this: |
19 // func BenchmarkHello(b *testing.B) { | 19 // func BenchmarkHello(b *testing.B) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 println("--- PASS:", tests[i].Name) | 165 println("--- PASS:", tests[i].Name) |
166 print(t.errors) | 166 print(t.errors) |
167 } | 167 } |
168 } | 168 } |
169 if !ok { | 169 if !ok { |
170 println("FAIL") | 170 println("FAIL") |
171 os.Exit(1) | 171 os.Exit(1) |
172 } | 172 } |
173 println("PASS") | 173 println("PASS") |
174 } | 174 } |
OLD | NEW |