Skip to content

Improvement: Add unit tests for cr_checker using pytest and Bazel #177

Open
@nradakovic

Description

@nradakovic

Background

The cr_checker tool currently lacks unit tests, which compromises its reliability and increases the risk of regressions during updates. Unit testing is essential for validating functionality, identifying issues early, and maintaining a stable tool. Additionally, integrating pytest with the Bazel build system aligns with our existing workflows and ensures consistent test execution across environments.

Objectives

  • Write comprehensive unit tests for cr_checker using pytest to achieve robust coverage.
  • Integrate pytest into the Bazel build system to standardize testing and enable automation in CI/CD workflows.

Acceptance Criteria

  • A suite of unit tests is implemented for cr_checker, covering critical functionality and edge cases.
  • pytest is successfully integrated with Bazel, allowing tests to run seamlessly through Bazel commands.
  • Tests are runnable both locally and in the CI pipeline without additional manual steps.
  • Documentation is provided for running and maintaining the tests.

Proposed Steps

  1. Analyze Tool Functionality:

    • Review the codebase of cr_checker to identify the key components and their functionalities.
    • Outline critical paths and edge cases that require testing.
  2. Develop Unit Tests:

    • Use pytest to write tests for individual functions and modules.
    • Ensure high test coverage by addressing all major use cases and failure scenarios.
  3. Integrate Pytest with Bazel:

    • Create or modify Bazel rules to include pytest-based testing.
    • Ensure pytest is correctly configured to work within the Bazel environment.
  4. Verify and Validate:

    • Run tests locally via Bazel to confirm they execute successfully.
    • Integrate the tests into the CI pipeline and verify the workflow.
  5. Document the Process:

    • Provide clear instructions for running the tests with Bazel.
    • Include guidelines for writing and adding new tests in the future.

Resources

pytest documentation
py_test Bazel rules

Metadata

Metadata

Assignees

Type

Projects

Status

Todo

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions