Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Junit Merger Cli Laravel Package

sweetchuck/junit-merger-cli

CLI tool to merge multiple JUnit XML reports into a single file. Reads file paths from stdin or arguments, outputs to stdout or a specified file. Supports DOM-based and fast substring handlers, with an option to recalculate testsuite counts.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • CI/CD Pipeline Optimization: Enables consolidation of parallelized test reports (e.g., Pest/PHPUnit --parallel) into a single JUnit XML file for unified reporting in tools like SonarQube, Codecov, or Jenkins. Directly addresses test reliability and debugging efficiency in Laravel projects.
  • Test Suite Scalability: Supports distributed testing (e.g., microservices, modular Laravel apps) by merging fragmented reports into a cohesive output for compliance or auditing. Aligns with scalable architecture initiatives.
  • Build vs. Buy: Avoids reinventing a custom solution for JUnit merging, reducing technical debt and maintenance overhead. Justifies open-source adoption with minimal risk.
  • Observability & Debugging: Facilitates consolidated test logs for tracking flaky tests or performance regressions across Laravel’s test suite. Supports SRE goals for test stability.
  • Roadmap for Test Automation: Enables parallel test execution without sacrificing reporting consistency. Critical for performance-critical Laravel applications (e.g., APIs, high-traffic sites).
  • Laravel-Specific Use Cases:
    • Merging Pest/PHPUnit reports from parallelized test runs (e.g., --parallel --distribute).
    • Integrating with Laravel Forge/Envoyer for deployment-stage test validation.
    • Supporting Laravel Octane serverless deployments where test reports must be centralized.

When to Consider This Package

Adopt When:

  • Running parallelized test suites (e.g., Pest/PHPUnit --parallel) and needing a single JUnit report for CI tools.
  • Integrating with third-party tools (SonarQube, Coveralls, GitHub PR annotations) that require unified JUnit XML.
  • Merging test results from microservices or modular Laravel apps where tests execute independently.
  • Prioritizing simplicity and speed over custom test metadata transformations (e.g., no need for filtering/rewriting attributes).
  • Using Laravel’s built-in testing tools (Pest, PHPUnit) but lacking native support for parallel report consolidation.
  • CI/CD pipelines where test reports are scattered across artifacts (e.g., GitHub Actions, GitLab CI).

Look Elsewhere If:

  • Requiring advanced test metadata manipulation (e.g., filtering, rewriting attributes, custom tags).
  • Using non-JUnit XML formats (e.g., custom reporters like spatie/laravel-test-failures with extended schemas).
  • Needing real-time merging (this is a CLI tool; for programmatic use, consider forking the library).
  • Preferring built-in solutions (e.g., PHPUnit’s native parallelization tools or CI-native merging like GitHub Actions’ test-results).
  • XML schema validation is critical, and the substr handler risks malformed output.
  • The Laravel project uses serverless/headless environments where CLI tools are restricted (e.g., AWS Lambda).

How to Pitch It (Stakeholders)

For Executives:

*"This CLI tool solves a critical bottleneck in our test automation pipeline: merging fragmented JUnit reports from parallelized test runs into a single, standardized output. It’s a turnkey solution that:

  • Reduces debugging time by consolidating test logs for flaky tests or regressions.
  • Improves CI reliability by ensuring consistent reporting for tools like SonarQube and Codecov.
  • Eliminates custom dev work, saving [X] hours/year on reinventing merging logic.
  • Supports scalability for distributed Laravel apps or microservices.

With a one-liner integration in our CI pipeline, we can ensure test reporting consistency across environments—directly supporting our goals for [QA efficiency/automation/observability]. The risk is minimal: it’s a battle-tested PHP tool with no Laravel-specific dependencies."*

For Engineering/DevOps:

*"The junit-merger-cli package lets us consolidate JUnit XML files from parallel Pest/PHPUnit runs (e.g., --parallel --distribute) into a single file for tools like SonarQube or Jenkins. Here’s why it’s a no-brainer:

  • Seamless CI Integration: Works with find or direct file arguments. Example:
    # Merge all JUnit files in a directory and pipe to SonarQube
    find tests/_output -name '*.xml' | junit-merger merge:files > merged-report.xml
    
  • Flexible Handlers: Choose between:
    • dom_read_write (accurate, recalculates test suite stats).
    • substr (fast, for identical-format files).
  • Zero Laravel Conflicts: Pure PHP, no dependencies. Can be called via shell_exec or wrapped in an Artisan command.
  • Future-Proof: Aligns with Laravel’s parallel testing trends and observability initiatives.

Trade-offs:

  • Sacrifices some customization for simplicity.
  • dom_read_write may be slower for 1000+ files (benchmark with our test suite).

Next Steps:

  1. Test with a parallel Pest run and validate merged output in SonarQube.
  2. Wrap in an Artisan command for Laravel-native usage (e.g., php artisan junit:merge).
  3. Add to CI pipeline as a post-test step.

This avoids reinventing the wheel while keeping our workflows lean."*


For Developers:

*"If you’re running parallel tests (Pest/PHPUnit --parallel) and struggling with scattered JUnit reports, this tool is your CI lifesaver. Here’s how to use it in Laravel:

  1. Install:
    composer require sweetchuck/junit-merger-cli
    
  2. Merge Reports:
    # Option 1: Pipe from `find`
    find storage/logs/junit -name '*.xml' | vendor/bin/junit-merger merge:files > merged.xml
    
    # Option 2: Direct files (with handler)
    vendor/bin/junit-merger merge:files --handler='dom_read_write' file1.xml file2.xml --output-file=merged.xml
    
  3. Laravel Integration (optional): Create an Artisan command to automate this:
    // app/Console/Commands/MergeJUnitReports.php
    class MergeJUnitReports extends Command {
        protected $signature = 'junit:merge {--output= : Output file}';
        public function handle() {
            $files = glob(storage_path('logs/junit/*.xml'));
            $output = $this->option('output') ?: storage_path('logs/junit/merged.xml');
            shell_exec("php vendor/bin/junit-merger merge:files " . implode(' ', $files) . " > $output");
        }
    }
    
    Then run:
    php artisan junit:merge --output=storage/logs/junit/report.xml
    

Pro Tip: Use --handler='substr' for speed if your test files are identically formatted (e.g., from the same PHPUnit run). Use dom_read_write for accuracy (recalculates test counts).

Debugging: If the merged XML looks wrong, check:

  • Input file validity (SimpleXML can validate).
  • Handler choice (try dom_read_write for strict parsing).
  • File encoding (ensure UTF-8)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle