Skip to content

Commit

Permalink
added some info to Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex da Franca committed Jun 13, 2021
1 parent 8f0e499 commit 5790218
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,48 @@ Interpret binary .xcresult files and print summary in different formats:

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. If present paths and urls are relative to the specified directory. (used for urls in xml output)
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](https://github.com/davidahouse/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]( https://github.com/SonarSource/sonar-scanning-examples/blob/master/swift-coverage/swift-coverage-example/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.

## Examples

### Colored CLI output
Print the test results in color to the command line:
```
./xcresultparser -o cli test.xcresult
```
![Colored command line output](images/cliColor.png)

### HTML output
Create a single html file with test data
```
./xcresultparser -o html test.xcresult > testResult.html
```
![Interactive single page HTML file](images/testResultHTML.png)

### 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
```
Binary file added images/cliColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/testResultHTML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions xcresultparser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
FA042FDC26760F6900A729F7 /* cliColor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cliColor.png; sourceTree = "<group>"; };
FA042FDD267610E900A729F7 /* testResultHTML.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = testResultHTML.png; sourceTree = "<group>"; };
FA1D13772674D7680076C07F /* HelperFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HelperFunctions.swift; sourceTree = "<group>"; };
FAC76A232673E8FA001D7398 /* xcresultparser */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = xcresultparser; sourceTree = BUILT_PRODUCTS_DIR; };
FAC76A262673E8FA001D7398 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -64,12 +66,22 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
FA042FDB26760F1D00A729F7 /* images */ = {
isa = PBXGroup;
children = (
FA042FDD267610E900A729F7 /* testResultHTML.png */,
FA042FDC26760F6900A729F7 /* cliColor.png */,
);
path = images;
sourceTree = "<group>";
};
FAC76A1A2673E8FA001D7398 = {
isa = PBXGroup;
children = (
FAC76A322673EA18001D7398 /* README.md */,
FAC76A312673EA18001D7398 /* LICENSE */,
FAC76A252673E8FA001D7398 /* xcresultparser */,
FA042FDB26760F1D00A729F7 /* images */,
FAC76A242673E8FA001D7398 /* Products */,
);
sourceTree = "<group>";
Expand Down

0 comments on commit 5790218

Please sign in to comment.