简体   繁体   English

“Go for Visual Studio Code”中的文件扩展名 test.go

[英]File extension test.go in "Go for Visual Studio Code"

I have installed the extension named "Go for Visual Studio Code" v0.35.2 Rich Go language support for Visual Studio Code.我已经为 Visual Studio Code 安装了名为“Go for Visual Studio Code”v0.35.2 Rich Go 语言支持的扩展。

The extension is working properly on files named .go该扩展在名为.go的文件上正常工作

On files named ...test.go it does not do anything.在名为...test.go 的文件上,它不执行任何操作。 Where can I change this so that my test.go files are also affected by the extension?我在哪里可以更改它,以便我的 test.go 文件也受到扩展的影响?

You can have a look at the tutorial for guidance.您可以查看教程以获取指导。

If you have a file foo.go that you want to test, create a foo_test.go in the same package with your tests inside.如果您有要测试的文件foo.go ,请在同一个 package 中创建一个foo_test.go和您的测试。

Start your test functions with Test and pass them the *testing.T parameter.使用Test启动您的测试函数并将*testing.T参数传递给它们。

Example:例子:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM