Goal of this event was to add tests (XCTest, Specta / Expecta , Kiwi or Cedar) to the projects (THSegmentedPager in my case) to reach a certain coverage and add the project to the Travis-CI Continuous Integration service as well as to the Coveralls test coverage service.
In this article I'll skip the creation of the tests itself (Those can be seen in the repository and watching the Pull Request that he sent when everything was done) and jump directly to the Travis-CI and Coveralls.io integration.
Travis-CIIf your project is already on Github you could navigate to Travis-CI connect it with your Github account and enable it for Travis-CI. If not you'll need to do it at the end of the process and it will run with the next commit.
1) As the project uses CocoaPods he add a Gemfile with it as dependency which you can execute using bundler (sudo gem install bundler)
$ bundle install
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.7.0
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using claide 0.8.1
Using fuzzy_match 2.0.4
Using nap 0.8.0
Using cocoapods-core 0.37.2
Using cocoapods-downloader 0.9.0
Using cocoapods-plugins 0.4.2
Using netrc 0.7.8
Using cocoapods-trunk 0.6.1
Using cocoapods-try 0.4.5
Using colored 1.2
Using escape 0.0.4
Using molinillo 0.2.3
Using xcodeproj 0.24.2
Using cocoapods 0.37.2
Using bundler 1.10.3
Bundle complete! 1 Gemfile dependency, 21 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
2) Now he add the .travis.yml file which will tell to Travis what is exactly to do.
language: objective-cTo make this commands work we'll need to add the missing commands (rake and xcpretty)to the Gemfile and execute it again
- bundle exec pod install --project-directory=THSegmentedPagerExample
- set -o pipefail && bundle exec rake test | bundle exec xcpretty --test --color
- bundle exec pod lib lint --quick
source 'https://rubygems.org'The script in .travis.yml points to a rake target named "test" which he had to define in the Rakefile
desc 'Run tests'If you're not sure about how to write the script it is probably the best option to open a console; cd to the project root and run it
task :test do
command = "xcodebuild \
-workspace THSegmentedPagerExample/THSegmentedPagerExample.xcworkspace \
-scheme THSegmentedPagerExample \
-sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
system(command) or exit 1
task :default => :test
3) One more thing which is often forgotten is to share the scheme. This is done in Xcode
4) Now, as you'll probably want to show that you're using a CI service all that is left is to add a badge to the readme