Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unittests to slack-annotations #6

Closed
3 tasks
seanh opened this issue Nov 27, 2024 · 0 comments · Fixed by #9
Closed
3 tasks

Add unittests to slack-annotations #6

seanh opened this issue Nov 27, 2024 · 0 comments · Fixed by #9
Assignees
Labels
enhancement New feature or request

Comments

@seanh
Copy link
Contributor

seanh commented Nov 27, 2024

slack-annotations doesn't have any unittests: when you run make test (which is an alias for tox, which is an alias for tox -e tests) or when you open a PR and CI runs on GitHub Actions, it runs the tests in tests/unit/slack_annotations/ but those consist of only a couple of placeholder tests:

  1. There's test_help() and test_version(). These are actually real unit tests for the --help and --version command-line arguments, but nothing else in cli.py is tested.
  2. And there's test_it() which is just a placeholder test for core.py.

It would be good to fill this out with proper unittests.

Note that slack-annotations makes HTTP requests to the Hypothesis API. We don't want it to make real HTTP requests when you run the functests. Since slack-annotations uses HTTPX to send HTTP requests we may be able to use something like pytest-httpx or respx.

Done when

Note: it's okay to use some # pragma: no cover's to get make test coverage to pass if there are some parts of the code that are too awkward or not worthwhile to write tests for. Our approach to unittests is that we enforce 100% coverage but are pragmatic about using # pragma: no cover to get there if necessary.

Note: the code in this project was hacked together without a lot of care. You might find that you have to refactor it in order to make it unit-testable. You might find it helpful to write functests first (there's a separate issue for those: #7) as these will enable large-scale refactorings with confidence.

@seanh seanh added the enhancement New feature or request label Nov 27, 2024
@seanh seanh changed the title Add unittests Add unittests to slack-annotations Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants