Skip to content

Reduce builder core assertion blocks (#40)#198

Draft
leynos wants to merge 1 commit into
mainfrom
issue-40-reduce-large-assertion-blocks-in-builder-core-tests
Draft

Reduce builder core assertion blocks (#40)#198
leynos wants to merge 1 commit into
mainfrom
issue-40-reduce-large-assertion-blocks-in-builder-core-tests

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented May 22, 2026

Summary

This branch reduces the large assertion blocks in the builder core tests by moving repeated checks into semantic helper assertions and by parameterizing language command cases with rstest. The change is test-only and preserves the existing builder behaviour while making failures easier to interpret.

Closes #40.

Review walkthrough

Validation

  • cargo test tools::builder::core::tests: passed, 29 builder core tests.
  • make all: passed, including format checks, clippy configurations, default nextest with 4,122 passed tests, and 5 GitHub tool tests.
  • Assertion block scan: passed, no line in src/tools/builder/core/tests.rs exceeded three consecutive assertion macro lines.
  • coderabbit review --agent: attempted three times, but CodeRabbit returned usage-credit rate-limit errors before producing a review.

Notes

This branch does not change production code or feature parity status.

Summary by Sourcery

Refine builder core tests by extracting shared assertion helpers and parameterizing language command coverage without changing production behavior.

Enhancements:

  • Introduce reusable assertion helpers for builder core result and configuration validation to reduce duplication and improve failure readability.

Tests:

  • Rework language extension, build command, test command, serde, and default-field tests to use semantic helpers and rstest parameterization while preserving existing coverage.

Refactor builder core tests to replace dense assertion runs with
tracked semantic helpers and `rstest` parameterised cases.

Keep the change test-only so builder behaviour remains unchanged while
making future failures easier to read.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 167aadbb-4a9c-405d-8cd3-b17f7c82e875

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-40-reduce-large-assertion-blocks-in-builder-core-tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 22, 2026

Reviewer's Guide

Refactors builder core tests to use shared assertion helpers and rstest parameterization, reducing duplicated assertion blocks while preserving test coverage and semantics.

File-Level Changes

Change Details Files
Introduce reusable assertion helpers for builder domain types to replace large, duplicated assertion blocks.
  • Added pretty_assertions::assert_eq and #[track_caller] annotations to improve diff readability and error locations in test failures.
  • Implemented helper functions for common BuildResult patterns (success, failure with expected errors/warnings, defaulted fields).
  • Implemented helper functions for BuildRequirement roundtrips, BuilderConfig default validation, optional field checks, and log content checks.
  • Updated existing tests to use the new helpers instead of inlined assertion sequences.
src/tools/builder/core/tests.rs
Parameterize language-related tests with rstest to cover multiple cases declaratively instead of in monolithic tests.
  • Added rstest dependency usage and annotations for language extension, build command, and test command tests.
  • Replaced single tests that manually asserted multiple Language variants with rstest-based parameterized tests that pass Language value, expected program, and arguments as cases.
  • Kept coverage for all existing language variants while making individual failures easier to attribute to a specific case.
src/tools/builder/core/tests.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#40 Refactor src/tools/builder/core/tests.rs so that no test contains more than three consecutive assertion macro lines, using semantic helper assertions and/or parameterised tests where needed.
#40 Preserve existing behaviour and coverage while keeping the changes scoped to tests only (no production code changes) and ensuring all tests pass.
#40 Ensure any new comments or text introduced in the tests use En-GB spelling.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Health Improved (1 files improve in Code Health)

Gates Failed
Enforce advisory code health rules (1 file with Excess Number of Function Arguments)

Gates Passed
5 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
tests.rs 1 advisory rule 8.82 → 9.10 Suppress
View Improvements
File Code Health Impact Categories Improved
tests.rs 8.82 → 9.10 Large Assertion Blocks

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

Comment on lines +82 to +99
pub(super) fn assert_build_result_failure(
res: &BuildResult,
expected_error: &str,
expected_warnings: usize,
tests_passed: u32,
tests_failed: u32,
) {
assert_build_failure_contains(res, expected_error);
assert_eq!(
(
res.validation_warnings.len(),
res.tests_passed,
res.tests_failed,
res.registered,
),
(expected_warnings, tests_passed, tests_failed, false)
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ New issue: Excess Number of Function Arguments
assertions.assert_build_result_failure has 5 arguments, max arguments = 4

Suppress

@github-actions github-actions Bot added size: L 200-499 changed lines risk: medium Business logic, config, or moderate-risk modules contributor: core 20+ merged PRs scope: tool/builder Dynamic tool builder labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: medium Business logic, config, or moderate-risk modules scope: tool/builder Dynamic tool builder size: L 200-499 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor tests: reduce Large Assertion Blocks in src/tools/builder/core/tests.rs

1 participant