为了账号安全,请及时绑定邮箱和手机立即绑定

未定义的函数 - Ginkgo 测试

未定义的函数 - Ginkgo 测试

Go
九州编程 2023-07-26 10:06:31
我正在尝试使用Ginkgo测试库对函数执行一组测试。我有两个脚本:.├── solve.go└── solve_test.go我希望测试能够针对该Solve函数运行,solve.go因为它们都在同一个包中。当我执行测试时,控制台返回:# command-line-arguments [command-line-arguments.test]./solve_test.go:11:10: undefined: Solve./solve_test.go:12:10: undefined: Solve./solve_test.go:13:10: undefined: Solve./solve_test.go:14:10: undefined: Solve./solve_test.go:15:10: undefined: Solve./solve_test.go:16:10: undefined: Solve./solve_test.go:17:10: undefined: Solve./solve_test.go:22:2: undefined: Solvesolve.gopackage longest_vowel_chainimport "fmt"func Solve(s string) int {    for pos, char := range s {        fmt.Println(char, pos)    }    return 0}solve_test.gopackage longest_vowel_chainimport (    . "github.com/onsi/ginkgo"    . "github.com/onsi/gomega"    "testing")func TestSolve(t *testing.T) {    It("Basic tests", func() {        Expect(Solve("codewarriors")).To(Equal(2))        Expect(Solve("suoidea")).To(Equal(3))        Expect(Solve("ultrarevolutionariees")).To(Equal(3))        Expect(Solve("strengthlessnesses")).To(Equal(1))        Expect(Solve("cuboideonavicuare")).To(Equal(2))        Expect(Solve("chrononhotonthuooaos")).To(Equal(5))        Expect(Solve("iiihoovaeaaaoougjyaw")).To(Equal(8))    })}我正在使用 Go 1.12.5 我哪里出错了?谢谢!
查看完整描述

1 回答

?
扬帆大鱼

TA贡献1799条经验 获得超9个赞

您需要将源代码移至$GOPATH或使用go 模块。



查看完整回答
反对 回复 2023-07-26
  • 1 回答
  • 0 关注
  • 93 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信