{"id":34837311,"url":"https://github.com/arenadata/pytest_allure_spec_coverage","last_synced_at":"2025-12-25T16:10:42.431Z","repository":{"id":45868250,"uuid":"381348117","full_name":"arenadata/pytest_allure_spec_coverage","owner":"arenadata","description":"The pytest plugin aimed to display test coverage of the specs(requirements) in Allure","archived":false,"fork":false,"pushed_at":"2021-12-01T12:01:46.000Z","size":142,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2023-03-04T04:49:58.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arenadata.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":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2021-06-29T11:57:43.000Z","updated_at":"2023-02-08T15:53:33.000Z","dependencies_parsed_at":"2022-09-05T05:20:50.450Z","dependency_job_id":null,"html_url":"https://github.com/arenadata/pytest_allure_spec_coverage","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/arenadata/pytest_allure_spec_coverage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arenadata%2Fpytest_allure_spec_coverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arenadata%2Fpytest_allure_spec_coverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arenadata%2Fpytest_allure_spec_coverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arenadata%2Fpytest_allure_spec_coverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arenadata","download_url":"https://codeload.github.com/arenadata/pytest_allure_spec_coverage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arenadata%2Fpytest_allure_spec_coverage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28032399,"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","status":"online","status_checked_at":"2025-12-25T02:00:05.988Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-12-25T16:09:02.833Z","updated_at":"2025-12-25T16:10:42.424Z","avatar_url":"https://github.com/arenadata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pytest Allure Spec Coverage\n\nThe pytest plugin aimed to display test coverage of the specs(requirements) in Allure\n\n![image info](./img/allure.png)\n\n## Features\n\n* Show your uncovered specs along with the test results\n* Show your skipped specs in case if you run tests selectively\n* Link your test results and their respective scenarios\n* Add labels to your test results for the spec-related results view\n* Lint your code for mismatching specs and tests\n\n\n## Installation\n```shell\npip install pytest-allure-spec-coverage\n```\n\n## How to use\nWithout additional arguments this plugin does nothing. \nYou need to pass the collector type of your specs.\n```shell\npytest --sc-type sphinx ./tests\n```\n\nMake sure that your tests are linked with your specs.\nThis plugin adds a new mark `scenario`. Mark your tests with a unique spec id depending on your collector type. \n```python\nimport pytest\n\n@pytest.mark.scenario(\"something\")\ndef test_something():\n    pass\n```\n\n## Possible collectors\n### sphinx\nAt the moment only sphinx collector implemented. \nIt works with reStructuredText (.rst) files.\nValue for the `scenario` mark - `sphinx-dir`-related path to the spec file. Extension is ignored\n```\npath/\n  to/\n    something.rst\n```\n```python\n@pytest.mark.scenario(\"path/to/something\")\n```\n\nCollector arguments:\n\n`sphinx_dir` - where is placed your specs. \nAll of the .rst files in the directory and sub-folders will be perceived as specs.\nThe only exception - index.rst files. It will be used as the title of directories.\n\n`spec_endpoint` - optionally endpoint where is hosted your sphinx specs.\n\n`default_branch` - change it if your default repository branch differs from `master`. \nThe current branch gets from env variable `BRANCH_NAME` and is used to build the correct link to spec.\n\n### Your custom collector\nYou can easily implement your collector and register it for the plugin.\nSee `Collector` class for available methods.\n\n```python\n# conftest.py\nfrom pytest_allure_spec_coverage.models.collector import Collector\nfrom pytest_allure_spec_coverage.plugin import CollectorsMapping\n\nclass YourOwnCollector(Collector):\n    ...\n\ndef pytest_register_spec_collectors(collectors: CollectorsMapping) -\u003e None:\n    \"\"\"Register your own spec collector\"\"\"\n\n    collectors[\"yourowncollector\"] = YourOwnCollector\n```\nThat's all. Now you can choose it in your tests\n```shell\npytest --sc-type yourowncollector ./tests\n```\n\n\n## How to use spec collector as a linter\nFor the linter mode, we have the following options.\n\n`--sc-only` - enable linter mode. \nIf spec coverage percent is lower than `--sc-target` value, you get a non-zero exit code and error message.\n\n`--sc-target` - target percent for the spec coverage. The default target is 100% - uncovered specs are not allowed.\n\nIf you use linter mode, tests won't start anyway. It's just the start collection stage and exit with zero or non-zero exit code. \nIt is convenient to use in your CI.\n\n## Reporting arguments\nYou can pass `allure_labels` setting with labels for building spec structure in test results.\nRecommended value for the [Allure2](https://github.com/allure-framework/allure2) is:\n```ini\n# pytest.ini\n[pytest]\nallure_labels =\n    epic\n    feature\n    story\n```\nBut you can use your custom labels if you needed.\n\n## Note\nIf you use Allure TestOps, spec coverage will be disabled in case of test run from TestOps, like re-run in existing launch\n\n\n## If you want to contribute\n### Pre-commit hook\n\nWe are using black, pylint, and pre-commit to care about code formatting and linting.\n\nSo you have to install pre-commit hook before you do something with code.\n\n``` sh\npip install pre-commit # Or do it with your preferred way to install pip packages\npre-commit install\n```\n\nAfter this, you will see the invocation of black and pylint on every commit.\n\n### Run tests\n\nTo run tests, execute within project root:\n\n```bash\npip install -e .\npytest src/pytest_allure_spec_coverage --doctest-modules --alluredir tests/allure-results\npytest -s -v --showlocals --alluredir tests/allure-results\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farenadata%2Fpytest_allure_spec_coverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farenadata%2Fpytest_allure_spec_coverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farenadata%2Fpytest_allure_spec_coverage/lists"}