Danger-slather
A Danger plugin that show code coverage of a Xcode project and file by file using Slather. Add warnings or fail the build if a minimum coverage are not achieved. It uses Slather Framework for calculate coverage, so it's required to configure the slather object before using it.
How does it look?
1 Error | |
---|---|
🚫 | Total coverage less than 80% |
1 Warnings | |
---|---|
⚠️ | AppDelegate.swift has less than 50% code coverage |
Code coverage
Total coverage: 35.0
File | Coverage |
---|---|
AppDelegate.swift | 10.00 |
ViewController.swift | 20.00 |
ViewController2.swift | 30.00 |
ViewController3.swift | 40.00 |
ViewController4.swift | 50.00 |
ViewController5.swift | 60.00 |
Powered by Slather
Installation
$ gem install danger-slather
Usage
First configure the slather object:
slather.configure("Path/to/my/project.xcodeproj", "MyScheme")
For a more complex case:
slather.configure("Path/to/my/project.xcodeproj", "MyScheme", options: {
workspace: 'Path/to/my/workspace.xcworkspace',
build_directory: 'Path/to/my/build_directory',
ignore_list: ['ignore file 1', 'ignore file 2'],
ci_service: :travis,
coverage_access_token: 'acc123123123123',
coverage_service: :terminal,
source_directory: 'Path/to/my/source_directory',
output_directory: 'Path/to/my/output_directory',
input_format: 'profdata',
binary_file: 'Path/to/my/output_directory',
decimals: 2
post: false
})
For a more complete documentation of all support configuration see Slather
Than just add this line to your Dangerfile
:
slather.notify_if_coverage_is_less_than(minimum_coverage: 80)
slather.notify_if_modified_file_is_less_than(minimum_coverage: 60)
slather.show_coverage
Development
- Clone this repo
- Run
bundle install
to setup dependencies. - Run
bundle exec rake spec
to run the tests. - Use
bundle exec guard
to automatically have tests run as you make changes. - Make your changes.