doulanli6146 2017-07-26 20:57
浏览 49

去测试错过执行路径上的覆盖率

Consider a file structure like this:

api --
     |_ routes.go
     |_ handler.go
impl--
     |_ impl.go
     |_ impl_test.go

The "impl" file contains internal implementation of REST APIs for which the handlers and routes are in "handler.go" and "route.go" files respectively.

As far as packaging goes, everything under "api" folder is in the "api" package. The code in "impl.go" is in "impl" package and the code in "impl_test" package is in "impl_test" package.

api -------
           |_ routes
           |_ handler functions
impl-------
           |_ impl functions
impl_test--
           |_ test functions

The test function starts a HTTP server listening to a local open port using the routes and handlers in the "api" package and then call the APIs.

However, the coverage report shows 0% coverage for the code in the "api" package and non-zero% for "impl".

Can someone please explain why the coverage is measured for one package and not the other? And whether there is way to fix this?

  • 写回答

1条回答 默认 最新

  • douan8473 2017-07-27 20:15
    关注

    In case someone using goconvey land in this question, this is an issue with the tool:

    https://github.com/smartystreets/goconvey/issues/491

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集