Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

dodobrands/DBXCResultParser-Sonar

DBXCResultParser-Sonar

⚠️ Notice: This formatter has been integrated into Peekie (formerly DBXCResultParser) as SonarFormatter. We recommend using Peekie instead of this repository for new projects and migrating existing projects to Peekie. Peekie provides the same SonarQube formatter functionality along with additional features, better maintenance, and active development.

The DBXCResultParser-Sonar package provides a Swift module for parsing .xcresult files generated by Xcode to produce Sonar Generic Test Execution Report .xml. It can be integrated into your CI/CD pipeline to enhance the visibility of test results in SonarQube or SonarCloud.

For new projects, please use Peekie which includes SonarFormatter with the same functionality.

Usage

As a Command Line Tool

You can use DBXCResultParser-Sonar as a command line tool in two ways:

  1. Prebuilt Binary from Xcode Archive:

    1. Clone repo
    2. Open in Xcode
    3. Product → Archive
    4. Distribute Content → Built Products
    5. Run exported binary:
    ./DBXCResultParser-Sonar --xcresult-path <path> --tests-path <your projects tests folder>
  2. Using Swift Run:

    Clone the repository and run the tool using the Swift Package Manager:

    git clone https://github.com/dodobrands/DBXCResultParser-Sonar.git
    cd DBXCResultParser-Sonar
    swift run DBXCResultParser-Sonar --xcresult-path <path> --tests-path <your projects tests folder>

Saving .xml report to file

You can save report in two ways:

  1. Using > operator:

    Append > at the end of any bash command to redirect it's output into file.

    ./DBXCResultParser-Sonar --xcresult-path <path> --tests-path <your projects tests folder> > sonar-test-report.xml
  2. Using --output-path option:

    Specify option for resulting file. May be useful when you've provided --verbode flag so that it's logs won't conflict with output .xml.

    ./DBXCResultParser-Sonar --xcresult-path <path> --tests-path <your projects tests folder> --output-path <path to resulting report.xml>

As a Dependency

To use DBXCResultParser-Sonar in your Swift package, add it to the dependencies for your Package.swift file:

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .package(url: "https://github.com/dodobrands/DBXCResultParser-Sonar", .upToNextMajor(from: "1.0.0"))
    ],
    targets: [
        .target(
            name: "YourTargetName",
            dependencies: ["DBXCResultParser"]
        )
    ]
)

To parse an .xcresult file and access the report data, initialize a DBXCReportModel with the path to the .xcresult file:

import DBXCResultParser_Sonar

let xcresultPath = URL(fileURLWithPath: "/path/to/your.xcresult")
let reportModel = try DBXCReportModel(xcresultPath: xcresultPath)
let formatter = SonarGenericTestExecutionReportFormatter()
let result = try formatter.sonarTestReport(from: reportModel)

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.

License

This project is licensed under the Apache License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages