{"id":16862317,"url":"https://github.com/dave/courtney","last_synced_at":"2025-04-05T21:08:42.598Z","repository":{"id":18847247,"uuid":"80924926","full_name":"dave/courtney","owner":"dave","description":"Courtney is a coverage tool for Go","archived":false,"fork":false,"pushed_at":"2024-09-08T23:46:12.000Z","size":74,"stargazers_count":168,"open_issues_count":15,"forks_count":28,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-13T14:35:32.773Z","etag":null,"topics":["coverage","coverage-files","go","golang","test-coverage","testing","testing-tools"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-04T14:35:17.000Z","updated_at":"2024-09-08T23:45:57.000Z","dependencies_parsed_at":"2024-10-13T14:46:02.455Z","dependency_job_id":null,"html_url":"https://github.com/dave/courtney","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave%2Fcourtney","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave%2Fcourtney/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave%2Fcourtney/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave%2Fcourtney/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dave","download_url":"https://codeload.github.com/dave/courtney/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coverage","coverage-files","go","golang","test-coverage","testing","testing-tools"],"created_at":"2024-10-13T14:35:10.141Z","updated_at":"2025-04-05T21:08:42.580Z","avatar_url":"https://github.com/dave.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/dave/courtney.svg?branch=master)](https://travis-ci.org/dave/courtney) [![Go Report Card](https://goreportcard.com/badge/github.com/dave/courtney)](https://goreportcard.com/report/github.com/dave/courtney) [![codecov](https://codecov.io/gh/dave/courtney/branch/master/graph/badge.svg)](https://codecov.io/gh/dave/courtney)\n\n# Courtney\n\nCourtney makes your code coverage more meaningful, by excluding some of the \nless important parts.\n\n1. Packages are tested with coverage.  \n2. Coverage files are merged.  \n3. Some code is less important to test. This is excluded from the coverage file.      \n4. Optionally we enforce that all remaining code is covered.\n\n# Excludes \nWhat do we exclude from the coverage report?\n\n### Blocks including a panic \nIf you need to test that your code panics correctly, it should probably be an \nerror rather than a panic. \n\n### Notest comments\nBlocks or files with a `// notest` comment are excluded.\n\n### Blocks returning a error tested to be non-nil\nWe only exclude blocks where the error being returned has been tested to be \nnon-nil, so:\n\n```go\nerr := foo()\nif err != nil {\n    return err // excluded \n}\n```\n\n... however:\n\n```go\nif i == 0 {\n    return errors.New(\"...\") // not excluded\n}\n```\n\nAll errors are originally created with code similar to `errors.New`, which is \nnot excluded from the coverage report - it's important your tests hit these. \n\nIt's less important your tests cover all the points that an existing non-nil \nerror is passed back, so these are excluded. \n\nA few more rules:\n* If multiple return values are returned, error must be the last, and all \nothers must be nil or zero values.  \n* We also exclude blocks returning an error which is the result of a function \ntaking a non-nil error as a parameter, e.g. `errors.Wrap(err, \"...\")`.  \n* We also exclude blocks containing a bare return statement, where the function \nhas named result parameters, and the last result is an error that has been \ntested non-nil. Be aware that in this scenario no attempt is made to verify \nthat the other result parameters are zero values.  \n\n# Limitations  \n* Having test coverage doesn't mean your code is well tested.  \n* It's up to you to make sure that your tests explore the appropriate edge \n  cases.  \n\n# Install\n```\ngo get -u github.com/dave/courtney \n```\n\n# Usage\nRun the courtney command followed by a list of packages. Use `.` for the \npackage in the current directory, and adding `/...` tests all sub-packages \nrecursively. If no packages are provided, the default is `./...`.\n\nTo test the current package, and all sub-packages recursively: \n```\ncourtney\n```\n\nTo test just the current package: \n```\ncourtney .\n```\n\nTo test the `a` package, it's sub-packages and the `b` package: \n```\ncourtney github.com/dave/a/... github.com/dave/b\n```\n\n# Options\n### Enforce: -e\n`Enforce 100% code coverage.`\n\nThe command will exit with an error if any code remains uncovered. Combining a \nCI system with a fully tested package and the `-e` flag is extremely useful. It \nensures any pull request has tests that cover all new code. For example, [here \nis a PR](https://github.com/dave/courtney/pull/5) for this project that lacks \ntests. As you can see the Travis build failed with a descriptive error. \n\n### Output: -o\n`Override coverage file location.`\n\nProvide a custom location for the coverage file. The default is `./coverage.out`.\n\n### Test flags: -t\n`Argument to pass to the 'go test' command.`\n\nIf you have special arguments to pass to the `go test` command, add them here. \nAdd one `-t` flag per argument e.g.\n```\ncourtney -t=\"-count=2\" -t=\"-parallel=4\"\n```\n\n### Verbose: -v\n`Verbose output`\n\nAll the output from the `go test -v` command is shown.\n\n# Output\nCourtney will fail if the tests fail. If the tests succeed, it will create or\noverwrite a `coverage.out` file in the current directory.\n\n# Continuous integration\nTo upload your coverage to [codecov.io](https://codecov.io/) via \n[travis](https://travis-ci.org/), use a `.travis.yml` file something like this:\n\n```yml\nlanguage: go\ngo:\n  - 1.x\nnotifications:\n  email:\n    recipients: \u003cyour-email\u003e\n    on_failure: always\ninstall:\n  - go get -u github.com/dave/courtney\n  - go get -t -v ./...\nscript:\n  - courtney\nafter_success:\n  - bash \u003c(curl -s https://codecov.io/bash)\n```\n\nFor [coveralls.io](https://coveralls.io/), use something like this:\n\n```yml\nlanguage: go\ngo:\n    - 1.x\nnotifications:\n  email:\n    recipients: \u003cyour-email\u003e\n    on_failure: always\ninstall:\n  - go get -u github.com/mattn/goveralls\n  - go get -u github.com/dave/courtney\n  - go get -t -v ./...\nscript:\n  - courtney\nafter_success:\n  - goveralls -coverprofile=coverage.out -service=travis-ci\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdave%2Fcourtney","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdave%2Fcourtney","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdave%2Fcourtney/lists"}