【问题标题】:File extension test.go in "Go for Visual Studio Code"\"Go for Visual Studio Code\" 中的文件扩展名 test.go
【发布时间】:2022-09-23 14:44:01
【问题描述】:

我已经为 Visual Studio Code 安装了名为“Go for Visual Studio Code”v0.35.2 Rich Go 语言支持的扩展。

该扩展在名为的文件上正常工作。去

在名为的文件上...test.go它不做任何事情。我在哪里可以更改它以便我的 test.go 文件也受到扩展的影响?

  • 不要将文件命名为 test.go!模式 *_test.go 是为测试保留的。也不要命名模块测试。

标签: go visual-studio-code


【解决方案1】:

您可以查看tutorial 以获得指导。

如果您有要测试的文件foo.go,请在包含测试的同一包中创建foo_test.go。

使用Test 启动您的测试函数,并将*testing.T 参数传递给它们。

例子:

TestHello(t *testing.T) {
   // call your actuel hello function and make your assertions below
}

【讨论】:

    猜你喜欢
    • 2020-12-02
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    • 1970-01-01
    • 2015-11-22
    • 1970-01-01
    相关资源
    最近更新 更多