Skip to content

Improve test orginization #199

Closed
@reactive-firewall

Description

@reactive-firewall

Improve Test Organization

Idea

Reorganize tests - from #184

1. Issue Summary and Initial Proposal

  • Issue Improve test orginization #199, titled "Improve test organization," originated as a follow-up to a prior discussion in Issue Release Candidate for Version 2.0.0 #184. The principal objective is to reorganize and refine the structure of tests within the "multicast" project in a manner that promotes clarity, selective test execution, and maintainability.
  • The initial post references an excerpt from tests/__init__.py, illustrating the existing arrangement of test suites. This excerpt demonstrates a variety of test classes aggregating basic functionality tests, build and packaging tests, integration tests, server-related tests, data processing tests, and more.

2. Early Commentary and Proposed Improvements

  • In an ensuing comment, the project maintainer (reactive-firewall) requested adjustments permitting both the comprehensive execution of tests and the selective invocation of specific test suites (e.g., from within a Makefile). They also sought insights into best current practices (BCPs) in testing and how the current codebase aligns with these principles.
  • The assistant (coderabbitai) responded by providing an in-depth architectural proposal:
    • Analyzed the project's alignment with conventional testing practices, lauding its modular test organization, descriptive test names, and resource cleanup.
    • Identified the absence of a mechanism for selective test suite execution and offered a solution involving Python's unittest framework, encompassing custom loaders (via unittest.TestLoader and unittest.TestSuite). This approach preserves the familiar make test pattern while adding additional Makefile targets for selective testing.
    • Demonstrated how coverage reporting and backward compatibility could remain intact by integrating a specialized runner script (e.g., tests/run_selective.py).

3. Evolving Requirements: Grouping Tests by Category

  • In a later comment, reactive-firewall provided a more refined strategy: grouping unit tests into distinct categories:
    • "minimum acceptance tests" (e.g., basic, doctests, SAY tests for multicast/send.py),
    • separate categories for extra tests (linting, security, coverage-focused items),
    • a future category for fuzzing tests (time-intensive, requiring specialized coverage or input generation), and
    • another future category for performance or scalability tests.
  • coderabbitai built upon these suggestions by proposing structured dictionaries (e.g., MINIMUM_ACCEPTANCE_TESTS, EXTRA_TESTS, etc.) that list test suites relevant to each grouping. The approach preserves backward compatibility yet accommodates incremental expansions in fuzzing and performance testing.

4. Further Development: Makefile Integration

  • The discussion then shifted toward practical integration with existing build scripts. The proposed Makefile additions:
    • Provided new targets (e.g., test-mat, test-extra, test-fuzzing, test-perf) to invoke specific groups or categories of tests.
    • Retained coverage instrumentation via $(COVERAGE) run -p --source=multicast to ensure that the newly stratified tests remain fully measured.
  • The conversation addressed enabling or disabling this structure at runtime (for instance, via environment variables such as TESTS_USE_PYTEST) to maintain dual support for unittest and pytest.

5. Tox Integration and Pending Future Steps

  • In the latest comments, reactive-firewall proposed including tox configurations into this reorganization, thus enabling consistent test environments across various Python versions or environments. This secondary layer would further unify the recommended approach, bridging local development with continuous integration scenarios.

6. Conclusion and Next Actions

  • The discourse has delivered a structured blueprint for reorganizing tests into multiple categories that can be selectively invoked. This structure leverages both unittest and, potentially, pytest-based workflows through environment variables.
  • The conversation remains open to subsequent refinements, particularly concerning performance tests, fuzzing expansions, and the final incorporation of tox. The discussion has fostered agreement on a test architecture that prioritizes maintainability, clarity, and modular extensibility.

Metadata

Metadata

Labels

CIContinuous Integration ToolingMulticastAny main project file changesPython LangChanges to Python source codeTestingSomething can be verifieddocumentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

Status

Archive Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions