You can use Codecov automatically as long as the repository's owner is a paid Codecov member (assuming this is a private repo).
xcov
xcov generates nicely formatted HTML code coverage reports, and is triggered with every fastlane test. The results are located in the app/build/xcov folder, just open index.html. When run on CircleCI they stored as build artifacts.
xcov also works with Danger to provide code coverage feedback on every pull request. You can also trigger it manually. The include_targets filtering is to exclude external stuff like CocoaPods, but for some reason thinks the target product name for debug-PRODUCTNAME is develop-PRODUCTNAME.app.
You should add other internal frameworks to include_targets inside the Dangerfile and Fastfile as development progresses.
# Manually
# fastlane will run xcov for you
$ bundle exec fastlane test
# when run manually, you must first build via `fastlane test` to generate Xcode's internal code coverage reports
$ bundle exec xcov -w app/PRODUCTNAME.xcworkspace/ -s debug-PRODUCTNAME --include_targets "develop-PRODUCTNAME.app, Services.framework" -o app/build/xcov
# Fastfile
xcov(
workspace: "PRODUCTNAME.xcworkspace",
scheme: "debug-PRODUCTNAME",
output_directory: "#{ENV['RZ_TEST_REPORTS']}/xcov",
# For some reason coverage is on the "develop-" app target instead of "debug-"
include_targets: "develop-PRODUCTNAME.app, Services.framework",
)
# Dangerfile
xcov.report(
workspace: "#{src_root}/PRODUCTNAME.xcworkspace",
scheme: "debug-PRODUCTNAME",
output_directory: "#{ENV['RZ_TEST_REPORTS']}/xcov",
# For some reason coverage is on the "develop-" app target instead of "debug-"
include_targets: "develop-PRODUCTNAME.app, Services.framework",
ignore_file_path: "#{src_root}/fastlane/.xcovignore"
)
Slather
Slather is an alternative to xcov and is capable of generating more comprensive HTML reports (located in app/build/slather), as well as uploading to a number of code coverage services like Codecov and Coveralls. It is also integrated into fastlane test but you can run it manually.
There is a similar issue to xcov where the scheme for the app target cannot be found, so right now only Services is included.
# Using fastlane
$ bundle exec fastlane test
# Manually run and open HTML report
$ bundle exec slather coverage --show --html --scheme Services --workspace app/PRODUCTNAME.xcworkspace/ --output-directory app/build/slather app/PRODUCTNAME.xcodeproj/
# Fastfile
slather(
proj: "PRODUCTNAME.xcodeproj",
workspace: "PRODUCTNAME.xcworkspace",
# Only the Services scheme seems to work. It cannot find our app target schemes.
scheme: "Services",
output_directory: "#{ENV['RZ_TEST_REPORTS']}/slather",
html: "true",
)
Code Coverage
Codecov
You can use Codecov automatically as long as the repository's owner is a paid Codecov member (assuming this is a private repo).
xcov
xcov generates nicely formatted HTML code coverage reports, and is triggered with every
fastlane test
. The results are located in theapp/build/xcov
folder, just openindex.html
. When run on CircleCI they stored as build artifacts.xcov
also works with Danger to provide code coverage feedback on every pull request. You can also trigger it manually. Theinclude_targets
filtering is to exclude external stuff like CocoaPods, but for some reason thinks the target product name fordebug-PRODUCTNAME
isdevelop-PRODUCTNAME.app
.You should add other internal frameworks to
include_targets
inside theDangerfile
andFastfile
as development progresses.Slather
Slather is an alternative to
xcov
and is capable of generating more comprensive HTML reports (located inapp/build/slather
), as well as uploading to a number of code coverage services like Codecov and Coveralls. It is also integrated intofastlane test
but you can run it manually.There is a similar issue to
xcov
where the scheme for the app target cannot be found, so right now onlyServices
is included.