dougu7546 2016-02-01 22:18
浏览 14
已采纳

如何在旅途中将测试分为多个文件

I'm learning Go through writing a web app with the following structure

myapp/
  db/
    dbconf.yml
    migrations/
      *.sql
  handler
    modulea.go
    moduleb.go
  model
    init.go
    modulea.go
    moduleb.go
  myapp.go <-- this is my main package with main func

I added my some tests for the modulea in a file myapp_test.go on project root, I want to organize the tests by module but I dont know how-to

  • 写回答

1条回答 默认 最新

  • dsgsdg206050 2016-02-01 22:20
    关注

    You should place the tests for modulea in a file called modulea_test.go in the same folder and package as modulea.

    Unit tests should be tested in the same package as the functions being tested.

    Then to test it you can do go test ./... which will execute the tests for every package in your app.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真