Skip to content

[Low] Repeated test fixture setup: tokens_for() duplicated across test modules #230

@coderabbitai

Description

@coderabbitai

Description

The tokens_for test fixture helper is effectively duplicated across multiple test modules, creating unnecessary code duplication in test infrastructure.

Priority

Low – Test infrastructure quality issue, not blocking functionality.

Details

Affected locations:

  • src/parser/ast/parse_utils/params/tests.rs:10
  • src/parser/ast/parse_utils/type_expr/tests.rs:10

Current state:

  • tokens_for helper function is duplicated in at least two test modules
  • Each module maintains its own copy of the same fixture setup logic
  • Changes to fixture setup must be applied in multiple places

Impact

  • Maintenance burden: Changes to fixture setup require updates in multiple test files
  • Consistency risk: Fixture implementations can drift, causing subtle test behaviour differences
  • Code duplication: Violates DRY principle even in test code
  • Developer experience: Contributors may not realise the helper exists elsewhere and create more copies

Actionable Fix

Extract the shared fixture helper into one local test utility module.

Approach:

  1. Create a shared test utilities module (e.g., src/parser/ast/parse_utils/test_utils.rs or src/parser/test_helpers.rs)
  2. Move tokens_for (and any other shared test helpers) to the shared module
  3. Update test files to import from the shared utility module
  4. Remove duplicated implementations

Benefits:

  • Single source of truth for test fixtures
  • Consistent fixture behaviour across all tests
  • Easier to maintain and extend test infrastructure
  • Reduces test code duplication

References

Requested by

@leynos

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions