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:

https://play.golang.org/p/4zh7didcap


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -