Go cli 找不到我的测试 [英] Go cli cant find my tests
本文介绍了Go cli 找不到我的测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试在 golang 中运行我的测试时,出现以下错误
When i try to run my tests in golang i get the following error
testing: warning: no tests to run
我还尝试创建一个测试项目,看看它在其他项目中的行为是否相同,这些是我的 2 个文件.
I also tried to create a test project to see if it behaves the same in other projects these are my 2 files.
package test
func test() string {
return "test"
}
这是我的测试.
package test
import (
"testing"
"github.com/stretchr/testify/assert"
)
func testTest(t *testing.T) {
assert.Equal(t, "test", test(), "String was not test")
}
我尝试使用:
go test
go test -v
我还测试了 git bash 和 cmd 中的行为.我使用的是带有 Go 1.7.1 的 Windows 10.
Also i tested the behaviour in git bash and the cmd. Im using Windows 10 with Go 1.7.1.
我希望有人能帮助我.
推荐答案
测试函数必须以 Test
开头.尝试将您的函数重命名为 TestTest
.那应该解决它.完整信息在这里:https://golang.org/pkg/testing
Test functions must begin with Test
. Try renaming your function to TestTest
. That should fix it. Full info here: https://golang.org/pkg/testing
这篇关于Go cli 找不到我的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文