2017-09-13 20:00
浏览 52


The testing package is available in the go playground.

How can I use the go playground to demonstrate testing concepts, without access to go test?

My assumption is it's possible using the testing.RunTests function. My attempts to do so always generate only "testing: warning: no tests to run".


For context, my use case is for sharing quick examples of tests, examples and benchmarks with colleagues. I rely on go playground for sharing code snippets like this often.

图片转代码服务由CSDN问答提供 功能建议

testing 包可以在操场上使用。 \ n

我如何使用去操场来演示测试概念,而无需访问 go test

我的假设是可以使用testing.RunTests 功能。 我这样做的尝试始终只会生成“正在测试:警告:没有要运行的测试”。

示例: PvRCMdeXhX

对于上下文,我的用例是与同事快速共享测试示例,示例和基准测试。 我经常依赖去游乐场分享这样的代码片段。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • doubu5154 2017-09-13 20:13

    You need to use testing.Main:

    func main() {
        testSuite := []testing.InternalTest{
                Name: "TestCaseA",
                F:    TestCaseA,
        testing.Main(matchString, testSuite, nil, nil)

    If you want to use the "non deprecated", but unstable way:

    解决 无用
    打赏 举报

相关推荐 更多相似问题