duanpao4172 2014-09-16 22:34
浏览 27
已采纳

如何设置银杏测试套件?

I have inherited a Go project that consists of a lot of common files, a library of sorts, two executables, and theoretically a test suite. The test suite is being written after the fact. But I dislike the only way I've found of setting up is rather unpalatable

I'm using Ginkgo, and this is my starting directory structure

  • component1/component1.go
  • component2/component2.go
  • cmd1/cmd1.go
  • cmd2/cmd2.go
  • project_suite_test.go
  • component1_test.go

Each cmd?.go file will be compiled into a separate executable.

What I would like is a multi-file test suite, usually one file per component. Where do I put the files so that go test will find and run all of them, without leaving them here in the root of the project?

  • 写回答

2条回答 默认 最新

  • dongwu9647 2014-09-16 23:32
    关注

    You can use go test ./... in the root and it will go into child folders and execute the tests:

    component1/component1.go
    component1/component1_test.go
    component2/component2.go
    component2/component2_test.go
    cmd1/cmd1.go
    cmd1/cmd1_test.go
    cmd2/cmd2.go
    cmd2/cmd2_test.go
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?