DBXCResultParser-Sonar

1.0.0

dodobrands/DBXCResultParser-Sonar

What's New

1.0.0

2023-12-20T13:25:23Z

What's Changed

New Contributors

Full Changelog: https://github.com/dodobrands/DBXCResultParser-Sonar/commits/1.0.0

DBXCResultParser-Sonar

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.

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.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

Last updated: Thu Feb 29 2024 08:45:25 GMT-1000 (Hawaii-Aleutian Standard Time)