Your SlideShare is downloading. ×
0
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Unit Testing in iOS - Ninjava Talk

1,615

Published on

Talk I gave about unit testing for iPhone to the Ninjava group in Tokyo.

Talk I gave about unit testing for iPhone to the Ninjava group in Tokyo.

Published in: Technology, Education
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,615
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
45
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Presented by: Ross Sharrott Long Weekend KK Follow me/us: @rsharrott @long_weekend
  • 2.
    • IT & Sales Managers
    • Entrepreneurs
    • Geeks
    • Tokyo, Melbourne, New York
  • 3.  
  • 4.
    • B2C Apps
    • Contract Development
      • Specialize in iOS & Android
    • Consulting
      • Training
      • Mobile Strategy for Enterprise
      • App Development strategy & implementation
  • 5.
    • Practical > Theoretical
    • The world is not perfect.
    • We are lazy.
  • 6.
    • Why Unit Test?
    • Why don’t iOS Devs Do It?
    • The Tools
    • Q&A
  • 7.
    • Why Unit Test?
    • Why don’t iOS Devs Do It?
    • The Tools
    • Q&A
  • 8.  
  • 9.
    • It takes longer to write tests.
    • I’m the only developer (and I’m amazing)
    • That’s QA’s job (I’m a developer )
    • My code takes input from someone else.
    • My boss doesn’t give me enough time to test.
  • 10.  
  • 11.
    • Tests save time.
    • Your own code looks like new code after 6 months.
    • QA is there to help you find real / obscure problems, not regressions.
    • Unit testing is for what you do with inputs.
    • Your boss will give you some time to get started, just ask.
  • 12.
    • Why Unit Test?
    • Why don’t iOS Devs Do It?
    • The Tools
    • The future?
  • 13.
    • < SDK 2.2 had no unit testing at all.
    • Then Unit testing in Xcode, frankly, sucked.
      • Sentest reported the unit tests at build time.
      • Application State was inaccessible.
      • Logic tests only.
      • Hard to debug tests.
      • IDE integration was poor – non-existent.
  • 14.
    • Functional & Application testing basically did not exist.
    • Continuous Integration was nigh impossible.
    • We are all spoiled by the tools in most other worlds – selenium, _test, _cover, _mock
  • 15.
    • GHUnit
      • Made testing on the device & with state possible
    • FoneMonkey
      • Made selenium like testing possible
    • Various Others…
    • The problem:
      • No IDE integration, somewhat annoying to run.
  • 16.  
  • 17.
    • Why Unit Test?
    • Why don’t iOS Devs Do It?
    • The Tools
    • Q&A
  • 18.
    • Unit Testing:
      • GHUnit
      • OCUnit
      • Continuous Integration
    • UI & Integration:
      • Automator, FoneMonkey
      • iCuke, UISpec, etc.
  • 19.
    • Pros
      • Running a subset of tests.
      • Nice viewer to see the test results.
      • Setup/Teardown on class or methods
      • Can run on Continuous Integration
      • Can read Sentest so you can switch later
    • Con
      • Additional setup, required for every project
      • New versions of Xcode can break this setup
  • 20.  
  • 21.
    • Pros
      • Easy to run with Xcode (CMD + U)
      • Easy to create new tests (CMD + N)
      • (Almost) no setup
      • Can be run on Continuous Integration
    • Cons
      • No class setup/teardown
      • Must run the entire suite every time
  • 22.
    • New test: CMD+N
    • Objective-C Test Case
    • You get something like this:
    • - (void)testAppDelegate
    • {
    • id yourApplicationDelegate = [[UIApplication sharedApplication] delegate];
    • STAssertNotNil(yourApplicationDelegate, @&quot;UIApplication failed to find the AppDelegate&quot;);
    • }
  • 23.
    • Deinflector *bulldog = [[Deinflector alloc] init];
    • NSArray *results;
    • NSString* msg = @&quot;expected deinflected string did not match!”;
    • // Check deinflection types
    • results = [bulldog go:@&quot; かけた &quot;];
    • STAssertEqualStrings([[results objectAtIndex:0] word], @&quot; かけた &quot;, @&quot;1st %@&quot;);
    • STAssertEqualStrings([[results objectAtIndex:1] word], @&quot; かける &quot;, @&quot;2nd %@&quot;, msg);
    • STAssertEqualStrings([[results objectAtIndex:2] word], @&quot; かく &quot;, @&quot;3rd %@&quot;, msg);
  • 24.
    • CMD + U
    • Xcode will build & run the test suite
    • You get in console:
    • Test Case '-[CardTagTest testUpdateLevelCounts]' passed (0.345 seconds).
    • Test Suite 'CardTagTest' finished at 2011-10-20 05:44:39 +0000.
    • Executed 3 tests, with 0 failures (0 unexpected) in 1.528 (1.529) seconds
  • 25.
    • Good News:
      • It can be done using xcodebuild & the simulator
      • Most of the popular CI’s can work
    • Bad News:
      • Must have xcode installed – so need a mac
      • OCUnit doesn’t put out junit output by default
        • Tools exist for this
      • Not a lot of Code Coverage tools available yet
  • 26.
    • Automator
      • Test automator, uses javascript
      • Included in Instruments
    • iCuke
      • New to the scene, seems like a good start but we haven’t jumped in yet.
      • Future (testing) proof your projects: Set accessibility tags in your apps
  • 27. Follow me/us: @rsharrott @long_weekend

×