Giter Club home page Giter Club logo

Comments (3)

axw avatar axw commented on July 19, 2024

Directory structure does not necessarily imply a relationship between packages, even if that's usually the case. So you're right, running "gocov test" will not test subdirectories; it only tests the specified package. If you don't specify a package on the command line, it tests the package in the working directory.

It's not entirely clear to me what you want to see. You want to see coverage for your package and all packages in subdirectories? What I suggest you do is test each package using go test -coverprofile=..., and then combine the results using gocov convert. That can then be fed into gocov report or gocov annotate.

from gocov.

jeffchao avatar jeffchao commented on July 19, 2024

That's right. I want to see coverage for the package and all packages in subdirectories. It's true directory structure may not necessarily imply relationship, but to elaborate my use case: I have a package main for foo.go. In here, it may use packages from subdirectories. The intuition here is to organize the code in a modular fashion. The entire codebase in the example represents one service/component of a large system.

I thought it would be nice to run the test on the codebase as a whole. One thing I could do is to just make all subdirectory packages be the same package name as whatever my service/component is named.

Right now, my goal is two things: (1) to see an overall coverage percentage and (2) to page through the output of gocov annotate for the codebase.

I'll try your suggestion and circle back here tomorrow. Thanks!

from gocov.

jeffchao avatar jeffchao commented on July 19, 2024

Using standard go cover works from the above suggested solution. Moreover, plain simple go test ./... -cover works as well. Closing.

from gocov.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.