Git Product home page Git Product logo

xcresultparser's Introduction

xcresultparser

Overview

Parse the binary xcresult bundle from Xcode builds and testruns

Interpret binary .xcresult files and print summary in different formats:

  • txt
  • colored command line output
  • xml
  • html

In case of 'xml' JUnit format for test results and generic format (Sonarqube) for coverage data is used.

You can also specify the name of the project root. Paths and urls are then relative to the specified directory. (used for urls in xml output)

This tool can read test result data and code coverage data from an .xcarchive using the developer tools included in Xcode 11. Namely here: xcresulttool and xccov to get json data from .xcresult bundles.

Parsing the JSON is done using the great XCResultKit package.

Converting code coverage data

Unfortunately converting to the coverage xml format suited for e.g. sonarqube is a tedious task. It requires us to invoke the xccov binary for each single file in the project.

First we get a list of source files with coverage data from the archive, using xccov --file-list and then we need to invoke xccov for each single file. That takes a considerable amount of time. So at least we can spread it over different threads, so that it executes in parallel and is overall faster.

Until now we used xccov-to-sonarqube-generic.sh which does the same job, just in a shell script. It has the same problem and since it can not spawn it to different threads, it takes about 5x the time.

How to get it

Using homebrew

brew tap a7ex/homebrew-formulae
brew install xcresultparser

Download binary

  • Download xcresultparser.zip binary from the latest release
  • Copy xcresultparser to your desktop
  • Open a Terminal window and run this command to give the app permission to execute:
chmod +x ~/Desktop/xcresultparser

IMPORTANT NOTE: This binary is not notarized/certified by Apple yet. So you must go to SystemSettings:Security and explicitely allow the app to execute, after the first attempt to launch it in the terminal, in case you want to take the risk. I will try to notarize it asap and get rid of this 'Important note'.

Or build the tool yourself:

  • Clone the repository / Download the source code
  • Run swift build -c release to build xcresultparser executable
  • Run open .build/release to open directory containing the executable file in Finder
  • Drag xcresultparser executable from the Finder window to your desktop

How to install it

Using homebrew

brew tap a7ex/homebrew-formulae
brew install xcresultparser

Downloaded binary

Assuming that the xcresultparser app is on your desktop…

Open a Terminal window and run this command:

cp ~/Desktop/xcresultparser /usr/local/bin/

Verify xcresultparser is in your search path by running this in Terminal:

xcresultparser

You should see the tool respond like this:

Error: Missing expected argument '<xcresult-file>'

OVERVIEW: Interpret binary .xcresult files and print summary in different formats: txt, xml, html or colored cli output.

USAGE: xcresultparser [--output-format <output-format>] [--project-root <project-root>] [--coverage-targets <coverage-targets> ...] [--coverage ...] [--no-test-result ...] [--quiet ...] <xcresult-file>

ARGUMENTS:
  <xcresult-file>         The path to the .xcresult file.

OPTIONS:
  -o, --output-format <output-format>
                          The output format. It can be either 'txt', 'cli', 'html' or 'xml'. In case of 'xml' JUnit format for test results and generic format
                          (Sonarqube) for coverage data is used.
  -p, --project-root <project-root>
                          The name of the project root. If present paths and urls are relative to the specified directory.
  -t, --coverage-targets <coverage-targets>
                          Specify which targets to calculate coverage from
  -c, --coverage          Whether to print coverage data.
  -n, --no-test-result    Whether to print test results.
  -q, --quiet             Quiet. Don't print status output.
  -h, --help              Show help information.

Now that a copy of xcresultparser is in your search path, delete it from your desktop.

You're ready to go! 🎉

How to use it

The tool doesn't create any file. It justs outputs its results to standard out. It is up to you to write the output to a file, using redirection. For example, if you want to write the text output into a file named output.txt on your desktop:

./xcresultparser -o txt test.xcresult > ~/Desktop/output.txt

However, if all you need is to output the contents of the xcresult bundle to the terminal:

./xcresultparser -o cli test.xcresult

Examples

Colored CLI output

Print the test results in color to the command line:

./xcresultparser -o cli test.xcresult

Colored command line output

HTML output

Create a single html file with test data

./xcresultparser -o html test.xcresult > testResult.html

Interactive single page HTML file

Junit output

Create an xml file in JUnit format:

./xcresultparser -o xml test.xcresult > junit.xml

Sonarqube output

Create an xml file in generic code coverage xml format:

./xcresultparser -c -o xml test.xcresult > sonar.xml

xcresultparser's People

Contributors

a7ex avatar darrarski avatar liuyunclouder avatar weibel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.