A tool to generate test code coverage information for Swift.
Swift
559
118 commits
updated Aug 10, 2017
A tool to generate test code coverage information for Swift.
This project has been entirely obsoleted by the native code coverage generation support available in Swift 2 onwards. It is therefore no longer maintained or supported.
Install the swiftcov command line tool by running git clone for this repo followed by make install in the root directory.
$ swiftcov help
Available commands:
generate Generate test code coverage files for your Swift tests
help Display general or command-specific help
version Display the current version of SwiftCov
Run the tests and generate code coverage files. You can write any xcodebuild command as arguments for testing your project.
$ swiftcov generate
Usage: swiftcov generate [swiftcov options] xcodebuild [xcodebuild options] (-- [swift files])
$ swiftcov generate \
xcodebuild test \
-project Example.xcodeproj -scheme 'Example' \
-configuration Release -sdk iphonesimulator
Use the --output parameter to specify a destination directory for the coverage files.
If you think the coverage generation process is slow, you can specify the threshold option. It makes running faster to limit the count of the number of executions.
Currently, the default value of threshold option is 1 for performance reasons. Since some test cases may take a very long time generating coverage data, especially if some code paths are frequently hit (as is the case with loops).
$ swiftcov generate --output ./coverage --threshold 1 \
xcodebuild test \
-project Example.xcodeproj -scheme 'Example' \
-configuration Release -sdk iphonesimulator
--output OUTPUT_DIR specify output directory for generated coverage files.
--threshold LIMIT_COUNT specify the maximum number of hits you wish to measure. Reducing this number can drastically speed up SwiftCov.
--debug Output very verbose progress messages.
-- [swift files] Pass a space-separated list of files for which to measure code coverage, with either relative or absolute paths, after the -- at the end of your command.
e.g.
$ swiftcov generate --output ./coverage --threshold 1 \
xcodebuild test \
-project Example.xcodeproj -scheme 'Example' \
-configuration Release -sdk iphonesimulator \
-- ./ExampleFramework/*.swift
Display general or command-specific help.
Display the current version.
$ make install
$ cd Examples/ExampleFramework/
$ swiftcov generate --output coverage_ios \
xcodebuild test \
-project ExampleFramework.xcodeproj \
-scheme ExampleFramework-iOS \
-sdk iphonesimulator \
-configuration Release
Please see the generated coverage file!
$ gcovr --root . --use-gcov-files --html --html-details --output coverage.html --keep
See the generated coverage file.
Use codecov-bash global uploader.
# cirlce.yml
test:
override:
- sudo chown :wheel /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ *.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
- xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
- swiftcov generate --output coverage xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
post:
- bash <(curl -s https://codecov.io/bash)
Use coveralls-gcov.
# Gemfile
source "https://rubygems.org"
gem "coveralls-gcov"
# cirlce.yml
dependencies:
override:
- bundle install
test:
override:
- sudo chown :wheel /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ *.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
- xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
- swiftcov generate --output coverage xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
post:
- bundle exec coveralls-gcov --repo-token REPO_TOKEN --no-gcov
SwiftCov traces the execution of your test code using LLDB by following these steps:
.gcov files from those results.MIT licensed.
497 followers · starred Jun 2015
292 followers · starred Jun 2015
2,072 followers · starred Jun 2015
748 followers · starred Jun 2015
A tool to generate test code coverage information for Swift.
Swift
559
118 commits
updated Aug 10, 2017
A tool to generate test code coverage information for Swift.
This project has been entirely obsoleted by the native code coverage generation support available in Swift 2 onwards. It is therefore no longer maintained or supported.
Install the swiftcov command line tool by running git clone for this repo followed by make install in the root directory.
$ swiftcov help
Available commands:
generate Generate test code coverage files for your Swift tests
help Display general or command-specific help
version Display the current version of SwiftCov
Run the tests and generate code coverage files. You can write any xcodebuild command as arguments for testing your project.
$ swiftcov generate
Usage: swiftcov generate [swiftcov options] xcodebuild [xcodebuild options] (-- [swift files])
$ swiftcov generate \
xcodebuild test \
-project Example.xcodeproj -scheme 'Example' \
-configuration Release -sdk iphonesimulator
Use the --output parameter to specify a destination directory for the coverage files.
If you think the coverage generation process is slow, you can specify the threshold option. It makes running faster to limit the count of the number of executions.
Currently, the default value of threshold option is 1 for performance reasons. Since some test cases may take a very long time generating coverage data, especially if some code paths are frequently hit (as is the case with loops).
$ swiftcov generate --output ./coverage --threshold 1 \
xcodebuild test \
-project Example.xcodeproj -scheme 'Example' \
-configuration Release -sdk iphonesimulator
--output OUTPUT_DIR specify output directory for generated coverage files.
--threshold LIMIT_COUNT specify the maximum number of hits you wish to measure. Reducing this number can drastically speed up SwiftCov.
--debug Output very verbose progress messages.
-- [swift files] Pass a space-separated list of files for which to measure code coverage, with either relative or absolute paths, after the -- at the end of your command.
e.g.
$ swiftcov generate --output ./coverage --threshold 1 \
xcodebuild test \
-project Example.xcodeproj -scheme 'Example' \
-configuration Release -sdk iphonesimulator \
-- ./ExampleFramework/*.swift
Display general or command-specific help.
Display the current version.
$ make install
$ cd Examples/ExampleFramework/
$ swiftcov generate --output coverage_ios \
xcodebuild test \
-project ExampleFramework.xcodeproj \
-scheme ExampleFramework-iOS \
-sdk iphonesimulator \
-configuration Release
Please see the generated coverage file!
$ gcovr --root . --use-gcov-files --html --html-details --output coverage.html --keep
See the generated coverage file.
Use codecov-bash global uploader.
# cirlce.yml
test:
override:
- sudo chown :wheel /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ *.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
- xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
- swiftcov generate --output coverage xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
post:
- bash <(curl -s https://codecov.io/bash)
Use coveralls-gcov.
# Gemfile
source "https://rubygems.org"
gem "coveralls-gcov"
# cirlce.yml
dependencies:
override:
- bundle install
test:
override:
- sudo chown :wheel /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ *.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
- xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
- swiftcov generate --output coverage xcodebuild test -project Example.xcodeproj -scheme 'Example' -configuration Release -sdk iphonesimulator
post:
- bundle exec coveralls-gcov --repo-token REPO_TOKEN --no-gcov
SwiftCov traces the execution of your test code using LLDB by following these steps:
.gcov files from those results.MIT licensed.
497 followers · starred Jun 2015
292 followers · starred Jun 2015
2,072 followers · starred Jun 2015
748 followers · starred Jun 2015