• Save
Use Ruby to Write (and Test) Your Next Android App
Upcoming SlideShare
Loading in...5
×
 

Use Ruby to Write (and Test) Your Next Android App

on

  • 6,165 views

 

Statistics

Views

Total Views
6,165
Views on SlideShare
2,009
Embed Views
4,156

Actions

Likes
1
Downloads
0
Comments
0

7 Embeds 4,156

http://www.leandog.com 2875
http://leandog.com 1123
http://localhost 101
http://leandogsoftware.com 28
https://twitter.com 19
http://www.leandogsoftware.com 8
http://www.google.com 2
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Use Ruby to Write (and Test) Your Next Android App Use Ruby to Write (and Test) Your Next Android App Presentation Transcript

  • USE RUBY TO WRITE (AND TEST) YOUR NEXT ANDROID APPJoel BylerSoftware Craftsman@joelbylerJune 1, 2013Pittsburgh TechFestLa Roche CollegeSaturday, June 1, 13
  • WHO AM I? JOEL BYLER Software Craftsman Organizer for CleRb Enterprise Java Developer Relatively new to Ruby ... and AndroidSaturday, June 1, 13
  • Saturday, June 1, 13
  • NEW TO ANDROID AND RUBY??? Software CraftsmanshipReduce risk with TDD / ATDD <3 Ruby and want to learn more <3 Mobile apps, who doesn’t?Warning: this may turn out to be a lot of code to absorb in a shortamount of time. Slides and code will be made publicly availableSaturday, June 1, 13
  • RUBY ON ANDROID USING RUBOTOJRuby optimized for the Android OS JRuby is a JVM language Android uses something like the JVMbut actually Dalvik VM=+<<< MAGIC >>>Saturday, June 1, 13
  • IRB ON YOUR ANDROID DEVICE Interactive Ruby Shell Edit and run scripts in Android demo...Saturday, June 1, 13
  • PERFORMANCE CONSIDERATIONSOther than initial startup to loadJRuby, the performance of the appappears to be as good as manynative Android appsSaturday, June 1, 13
  • RUBOTO CORE A separate app available on theGoogle Play Store Allows Ruboto Runtime (JRubyon Dalvik VM) to be shared An alternative would be to usethe --with-jruby optionDecisions, decisions...Saturday, June 1, 13
  • HOW DOES THISMAKE YOU FEEL?This is what your users willsee if they don’t already havethe Ruboto Core installedUsing the --with-jrubyoption will add ~10mbto the size of your apporSaturday, June 1, 13
  • CREATE A NEW PROJECTRuboto Application Generator$ ruboto gen app --package com.leandog.mastermind.ruboto--name MasterMindRuboto --target android-15--with-jruby --path=RubotoMasterMindThis will generate application withWhat hath Matz wrought? sample code.Saturday, June 1, 13
  • RUBOTO CLASS GENERATORRuboto Class Generator$ ruboto gen class Activity --name MasterMindMainActivityThis will generate code for the activity and add it tothe project manifest.You can also use this to generate aBroadcastReceiver or Service classSaturday, June 1, 13
  • YOUR GENERATED APPSaturday, June 1, 13
  • YOUR GENERATED CODE (RUBY .RB)Saturday, June 1, 13
  • YOUR GENERATED TEST (ALSO .RB)Saturday, June 1, 13
  • RAKE INSTEAD OF ANT$ rake install startInstall the project on a device or emulator and startit running.$ ant debug$ adb install example.apk$ adb shell am start -n com.foo.bar...$ rake update_scriptsInstall the project on a device or emulator and startit running.$ adb install example.apk$ rake -T List other available rake tasksSaturday, June 1, 13
  • ADD IN THE ATDD$ gem install testgenThis is one of @chzy s testing gems$ testgen project yourapp --with-gametelThis will add everything you need to use cucumberto test your Ruboto appSaturday, June 1, 13
  • NOW FOR SOME UNIT TESTS$ mkdir spec This is where your specs will liveAdd rspec to Rakefile (created by testgen)Saturday, June 1, 13
  • UNIT TESTINGUse rspec to test your ruby code, just like younormally would.rspecJUnit 3rake specSaturday, June 1, 13
  • INTEGRATION TEST?Instruments and installs app on device when runningrake testsimilar to ActivityInstrumentationTestCase2Saturday, June 1, 13
  • ACCEPTANCE TESTINGFeature: Input ScreenScenario: Welcome the userWhen the application launchesThen I see "Enter four numbers below and submit your guess"Scenario: User can guessGiven I enter 4 numbersWhen I press the submit buttonThen I see "Nice guess!"rake featuresCucumberGametelBrazenheadADB gemclass MainScreeninclude Gameteltext(:number1, :index => 0)text(:number2, :index => 1)text(:number3, :index => 2)text(:number4, :index => 3)def guess (first, second, third, forth)number1 = first.to_snumber2 = second.to_snumber3 = third.to_snumber4 = forth.to_sendendThen(/^I enter 4 numbers$/) doon(MainScreen).guess 1, 2, 3, 4endSaturday, June 1, 13
  • YOUR RUBOTO CLASS FILES Theyre just .rb files Allows you to make changes without a fullrebuild fast feedback Ruboto uses ruby classes that are backed by javaclasses for improved performance. Can still reference Java resourcesexample:R::string::header_textSaturday, June 1, 13
  • QUICK TOUR OF THE CODE* Time permittingSaturday, June 1, 13
  • Saturday, June 1, 13
  • THE RUBOTO COMMUNITY IS GROWINGSome of these projects are still young or have a smalluser base.- They will probably continue to change (improve)- Ruboto is only version 0.12Example:Wasnt able to add a menu to the main activity. InsteadI had to wrap it with the launch activity.The good news is that they could definitely use YOURHELP!Anyone up for trying to make the debugger work?Saturday, June 1, 13
  • CONCLUSIONRuboto is a great Open Source project with agrowing community that promises to get evenbetter.Yes, it does increase your apps startup timeslightly, but offers a great dynamic nature forrapidly changing apps.Virtually all code can be Ruby, but can alsoreference Java resources if you so desire.Saturday, June 1, 13
  • RESOURCESSample Codehttps://github.com/joelbyler/Ruboto-MasterMindRubotohttp://ruboto.org/ATDD Training Resourcehttps://leanpub.com/cucumber_and_cheeseMore In-Depth Personal Traininghttp://www.TestAutomationBootCamp.com/Saturday, June 1, 13
  • DOMO ARIGATO MR. ROBOTO!Fun fact:domo arigato actually means"Thanks a lot!"in Japanesehttp://en.wikipedia.org/wiki/Domo_arigatoSo....Domo Arigato!Saturday, June 1, 13
  • THAT’S A WRAP!Joel Byler@joelbylerSaturday, June 1, 13
  • COME FLOAT WITH US!Located on a 10,000 square foot boat on theCleveland waterfront, our team exemplifieshow Agile values & principles are practiced.Come float, deliver, and learn with us, orleverage our expertise to help you changeyour company culture.@leandog www.leandog.comSaturday, June 1, 13