Created
June 24, 2015 00:33
-
-
Save vaskoz/98f2f1f0ec8f2cf0114c 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
thanks! 👍