duan111112 2019-07-25 13:12
浏览 89

去测试-空的覆盖文件

I have a go project, test directory contains a single sample test file. Few Functions of the test file are

func TestMain(m *testing.M) {
    setup()
    code := m.Run()
    shutdown()
    os.Exit(code)
}
func TestUserLogin(t *testing.T) {
    //sample code to make api call and validate response
}
func setup() {
    //start service
}
func shutdown() {
    //stop service
}

I want to see/generate a coverage report. The following command is being used to run tests:

go test -coverprofile=coverage.out

Output on terminal is

PASS
coverage: 100.0% of statements

coverage.out is getting generated but it consists of only single line

mode: set

coverage.out should have information about the files, lines, etc.

Anything that I am doing wrong here?

  • 写回答

1条回答 默认 最新

  • doujionggan9570 2019-07-25 18:46
    关注

    test directory contains a single sample test file

    Here it is, Go coverage does not work if your *_test.go files are not in the same directory a.k.a they have been put in another folder.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入