How do I use the testing package in go playground? -
the testing
package available in go playground.
how can use go playground demonstrate testing concepts, without access go test
?
my assumption it's possible using testing.runtests function. attempts generate "testing: warning: no tests run".
example: https://play.golang.org/p/pvrcmdexhx
for context, use case sharing quick examples of tests, examples , benchmarks colleagues. rely on go playground sharing code snippets often.
you need use testing.main
:
func main() { testsuite := []testing.internaltest{ { name: "testcasea", f: testcasea, }, } testing.main(matchstring, testsuite, nil, nil) }
https://play.golang.org/p/dqsigknwwd
if want use "non deprecated", unstable way:
Comments
Post a Comment