CI in the mobile world
Upcoming SlideShare
Loading in...5
×
 

CI in the mobile world

on

  • 4,954 views

Codemash 2012 presentation

Codemash 2012 presentation

Statistics

Views

Total Views
4,954
Views on SlideShare
4,180
Embed Views
774

Actions

Likes
7
Downloads
80
Comments
1

6 Embeds 774

http://riiscom0001.web705.discountasp.net 624
http://lanyrd.com 138
http://agile.riis.com 6
https://twitter.com 3
http://webcache.googleusercontent.com 2
https://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • DTE Outage Map and BroadSoft Front Office Assistant for setting up your office PBX
  • Cron jobs look to see what’s been checked in and runs tests
  • Perfecto Mobile
  • Goal is to jump start your CI efforts for your mobile projectsDownload presentation for Jenkins configuration information from github
  • This is not a TDD or BDD talk, there is no code, this is a jenkins configuration talk
  • As a business owner my perspective is happy customers, low defects, informed customers. CONSISTENT PROCESSES, how do you not sell it to your customers??
  • Give overview of what we’re trying to do
  • Dreamhost
  • Explain build.xml snafu
  • Executable tests not yet there for Android
  • Test flight app on iphone much nicer
  • Jenkins currently does not understand the standard OCunit framework.

CI in the mobile world CI in the mobile world Presentation Transcript

  • CI in the Mobile WorldGodfrey NolanRIIS LLCgodfrey@riis.com
  • Agenda• What is CI• Benefits of CI in Mobile World• CI Configuration • Android • iPhone• Still a work in progress • Perfecto Mobile • Test Flight App • Executable Requirements
  • Spam #1• RIIS LLC • Based in Southfield, MI• Mobile Development • Fandango • DTE Outage Maps • BroadSoft Front Office Assistant• Other Clients • BondDesk • Comerica • BCBSM
  • Spam #2
  • What is CI?• Automate everything • Soup to nuts • Build, test and deploy• Build as often as possible • Build early, build often • Typically on every checkin • Alternatively nightly builds• Practice, practice, practice
  • What is CI?• Automate …. • Builds • Unit testing • Functional testing. • Mobile Device Testing • Code Coverage • Deployment
  • Benefits of CI• Fewer Errors • iPhone vs. Android story• Faster Feedback• Repeatable and Reliable• No more manual testing • Cheaper• Built in regression testing
  • Benefits of CI in a Mobile World• Less complex • Mobile in its infancy • Typically smaller projects and teams• Lots of CI mobile plugins available• Easy deployment options • Testflight App (iPhone) • Email apk (Android)• Too many Android devices to manually test • Automated Device testing is the holy grail
  • Mobile Device Testing
  • Goal
  • Goal
  • It’s all about your perspective
  • CI Configuration Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • CI Server• Jenkins is de-facto industry standard• Currently the best choice • Number of plugins • Ease of use• Good for both Android and iPhone apps.
  • CI Server• Download from http://jenkins-ci.org/.• "java -jar jenkins.war" from cmd line• load Jenkins in browser at http://localhost:8080• RIP Hudson
  • CI Server
  • CI Server• Under Manage Jenkins, Configure System. • Add ant, JDK, and android SDK paths• Under Manage Jenkins, Plugin Manager. • Install XCode, GitHub and TestFlight
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Source Code Repository• Provides • Safety • Version Control etc.• Subversion (SVN) or GitHub • SVN for the Android project • GitHub for iPhone project
  • Android and iPhone projects
  • SVN• Create a new project on your SVN host
  • SVN• Using tortoise svn simply right click and say import.• Note that using the standard trunk tags and branches of svn will force you to specify your build.xml location in Jenkins because it will not be in the project root.
  • GitHub• Download Git from github.com• Create a new ssh key by entering the following command ssh-keygen –t rsa –C “your-email”• Enter a passphrase when prompted.• Click on GitHub.com account settings, SSH public keys, and click add a SSH Key.• Copy the contents of the id_rsa.pub and hit add key.
  • GitHub Cont.• To create a repository • Click create a repository on github.com • Fill in the requested fields. • git init in source code dir • git add (file(s) to be added) • git commit –m “message” • git push to push to GitHub
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Creating a Android Test Project• Create a new project AndroidCIDemo and select free style project.
  • Configuring a Android TestProject• Enter SVN details• Jenkins will alert you if it cannot access the URL• Be sure to enter credentials correctly
  • Configuring a Android Test ProjectCont.• Under the Build tab • Add commands to build/run the project. • Click on Add build step and select Execute shell. • Run android update project must be run in order to create the local.properties file.[path_to_android_sdk]/tools/android update project –p./[path_to_build.xml]• If android tools is already on your path and the build.xml file is in root than the command would be:Android update project –p ./• Add another build step Invoke Ant and add the target debug.• If build.xml file not in root hit advanced and specify its location in the build file field.
  • BuildNow build the project and hopefully it runs with no errors.
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Unit Tests• For unit tests in Android use built in JUnit framework.
  • Functional Tests• For Android Functional tests use Robotium• To implement Robotium all you have to do is add it to your test projects build path.• GUI based, i.e. brittle
  • Modifications to the Android Project• Both Unit and Functional tests are run in the same way.• To run android tests run an emulator during the build.• Under build environment choose Run an Android emulator during build. If you have already created an emulator using the android avd than you can choose to run that here, otherwise choose run emulator with properties.• Specify the OS version, Screen density and Screen resolution• Uncheck the Show emulator window box under Common emulator options to run headless.
  • Modifications Cont.• Add another Execute shell command: [path_to_android_sdk]/tools/android update test-project –p ./[path_to_test_project] –m ./[path_to_main_project].• And change the ant target to debug install test (don’t forget to change the build file if its not in root).
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Multi Configuration Job• For multiple device testing create matrix jobs • Specify variables to run multi test combinations • Run multiple emulators to make sure the app behaves same across different devices
  • Configuration Matrixes• Create a new project in Jenkins and choose matrix configuration job.• Same setup except we have to add one or more configuration matrixes.
  • Configuration Matrixes Cont.• Under the Configuration Matrix tab choose add axis.• Jenkins will than ask for a name and values. For example you can choose to create an emulator for different OS versions and screen densitys.• This matrix runs job on four different emulators.
  • Configure the Emulator• Now use variables instead of hard coded values.
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Android Deployment• Manage Jenkins->manage plugins.• Download email-extension plugin
  • Email Configuration• Go to email notification tab and check the box.• Choose a recipient, subject, and message. Under attachments give it the argument **/*.apk• Add trigger on success to choose who it’s sent to.
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Creating a iPhone Test Project• Create a new job IPhoneCIDemo with the option build free style
  • Configuring the IPhone TestProject• Go to the source control tab and select GitHub.• Copy your GitHub into Repository URL field• Specify a branch if not in the default branch.
  • Configuring the IPhone Test ProjectCont.• Go to the build tab and add a new build step XCode.• Change the XCode target to the target you want to build, and supply XCode project directory and file if not in root.• Fill in the XCode SDK field and change the Configuration field to default or debug.
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • iPhone Unit Tests• Use standard OCunit testing framework.• Jenkins uses Christian Hedlin’s Ocunit2junit ruby script • Converts the Xcode OCunit tests to JUnit tests. • Cannot run any tests that touch the UI.
  • Modifications to the IPhone Project • Remove test host values under the build settings • Add a new build step:xcodebuild -target yourtarget -configuration Debug -sdkiphonesdk | [path_to_ruby_script]/ocunit2junit.rb • Choose publish junit test results and give it the value test- reports/*.xml
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • iOS Functional Tests• Use FoneMonkey to run functional tests from CI.• Create automated tests by recording scripts and adding verification steps• Brittle GUI testing again 
  • FoneMonkey• To implement FoneMonkey first create a new target by duplicating the primary target.• Download the FoneMonkey Zip File and add it to the new target• Under the build phases tab of the FoneMonkey target go to the link with binary with libraries tab.• Click on the + button and add the CoreGraphics.framework and QuartzCore.framework.• You will also need to add the libxml2.dylib and SenTestingKit.framework• Lastly On the Build Settings tab, scroll down to the Linking section and set Other Linker Flags to -all_load
  • FoneMonkey Cont.• To be able to run FoneMonkey from the command line without having to start Xcode we need to create a TestRunner• Create a new target off of your FoneMonkey target• Add a run script to the TestRunner target under build phasesexport FONEMONKEY_HOME=~/[Location_of_Fone_Monkey]export FAMILY=[iphone|ipad]export LOG_FILE="$PROJECT_DIR/$TARGETNAME.log“export FONEMONKEY_ENV=$FONEMONKEY_HOME/FoneMonkeyRunner.plist rm -f "$LOG_FILE"$FONEMONKEY_HOME/bin/iphonesim launch "$CODESIGNING_FOLDER_PATH" -verbose -sdk$IPHONEOS_DEPLOYMENT_TARGET -family $FAMILY -stderr “ $LOG_FILE" -env"$FONEMONKEY_ENV“• You can now run this target from the command line and it will run your FoneMonkey tests for you.
  • FoneMonkey• The command to run the FoneMonkey TestRunner is xcodebuild –target TestRunnerTargetName –sdkiPhonesimulatorsdk –configuration Debug
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • iPhone Deployment• Use Test Flight App• Over the air beta testing• Test Flight app Jenkins plugin doesn’t work• But…all is not lost • Add a new build step and choose Xcode • Fill in the normal fields and choose to build IPA and unlock keychain as well. • Add keychain password.
  • iPhone Deployment • Add a build step execute shell and add the following commands:cd $WORKSPACE/build/Release-iphoneos/ curlhttp://testflightapp.com/api/builds.json-F file=@[IPA_FILE_NAME] -Fapi_token=[API_TOKEN] -F team_token=[TEAM_TOKEN] -Fnotes=This is an auto deploy build from Jenkins! -F notify=True -Fdistribution_lists=[DISTRIBUTION_LIST]• Team token and api token can be gotten from your testflight account
  • Requirements for CI Android IPhone Requirement CI Server Source Code Repository Project Build Unit Testing Functional Testing Mobile Device Testing Deployment
  • Conclusion• Work in Progress • Executable Requirements • Perfecto Mobile • Test Flight App• Demo• Followup • github.com/RIIS/RIIS-codemash.git • godfrey@riis.com • Android Application Testing Guide
  • Thanks• RIIS • Derek Verlee • David Armstrong • Brad Dunlap• Nayan Hajratwala