-
-
Save adam-stokes/9c9951730a9f87db4be7ecbff4d8d03a to your computer and use it in GitHub Desktop.
Run golang tests programatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"testing" | |
) | |
func Test1(t *testing.T) { | |
if 1+2 != 3 { | |
t.Fail() | |
} | |
} | |
func Test2(t *testing.T) { | |
if 3*3 == 9 { | |
t.Fail() // WHOOPS! | |
} | |
} | |
func Test3(t *testing.T) { | |
fmt.Println("Just wanted to print here") | |
} | |
func main() { | |
flag.Set("test.v", "true") | |
testing.Main(func(pat, str string) (bool, error) { return true, nil }, | |
[]testing.InternalTest{{"Test1String", Test1}, {"Test2String", Test2}, {"Test3String", Test3}}, | |
[]testing.InternalBenchmark{}, | |
[]testing.InternalExample{}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment