- Create a folder called `DangerDependencies` on `Sources` with an empty file inside like [Fake.swift](/dnrops/danger-swift-coverage/tree/master/Sources/DangerDependencies/Fake.swift)
- To run `Danger` use `swift run danger-swift command`
- (Recommended) If you are using SPM to distribute your framework, use [Rocket](https://github.com/f-meloni/Rocket), or similar to comment out all the dev depencencies from your `Package.swift`.
This prevents the dev dependencies to be downloaded and compiled with your framework.
#### Marathon
- Add this to your `Dangerfile.swift`
```swift
import DangerSwiftCoverage // package: https://github.com/f-meloni/danger-swift-coverage.git
Coverage.xcodeBuildCoverage(.derivedDataFolder("Build"),
minimumCoverage: 50,
excludedTargets: ["DangerSwiftCoverageTests.xctest"])
(Recommended) Cache the ~/.danger-swift folder
Gather Coverage
Enable “Gather the Coverage” on Xcode
or, on your CI, execute:
xcodebuild test -scheme DangerSwiftCoverage-Package -derivedDataPath Build/ -enableCodeCoverage YES
Custom XCResultBundle path
If you are using the -resultBundlePath parameter on xcodebuild you will need to use:
DangerSwiftCoverage
Danger-Swift plugin to show the coverage of the modified/created files.
Getting Started
Install DangerSwiftCoverage
Swift Package Manager (More performant)
You can use a “full SPM” solution to install both
danger-swift
andDangerSwiftCoverage
.Package.swift
:Dangerfile.swift
: ```swift import DangerSwiftCoverageCoverage.xcodeBuildCoverage(.derivedDataFolder(“Build”), minimumCoverage: 50, excludedTargets: [“DangerSwiftCoverageTests.xctest”])
~/.danger-swift
folderGather Coverage
or, on your CI, execute:
Custom XCResultBundle path
If you are using the
-resultBundlePath
parameter onxcodebuild
you will need to use:Swift Package Manager
From Swift 5.0 you can gather the coverage from SPM with the
--enable-code-coverage=true
flag For SPM coverage add to your Dangerfile:License
This project is licensed under the terms of the MIT license. See the LICENSE file.