Your SlideShare is downloading. ×
Unit testing_pps
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_pps

644

Published on

Published in: Technology, Education
1 Comment
1 Like
Statistics
Notes
  • A good starting point; Thank you!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
644
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
1
Likes
1
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. Unit Testing framework in iOS
  • 2. What?
    • What is Unit-Testing?
    • Available Unit Testing frameworks for iOS.
    • Basics of OCUnit Testing.
  • 3. Unit Testing
    • A Paradigm of Test-driven development.
    • Mainly of two types:
      • Logic Unit Testing
        • Testing a smallest logical unit or methods.
      • Application Unit Testing
        • Testing an entire application.
  • 4. Unit Testing Frameworks
    • Family of similar frameworks for testing various languages
      • Junit, Nunit, PyUnit etc.
    • OCUnit for Objective-C
      • Ships with MAC OS X developer tools,
      • Included in iPhone sdk 2.2.
  • 5. Why?
    • Fewer Bugs
      • More confidence that you’re shipping a high quality product.
    • Find bugs early .
      • Bugs are easier (and cheaper) to fix early in development.
    • Avoid regressions
      • Ensures that changing one piece of code doesn’t breaks another.
    • Document your code
  • 6. When and Who?
    • When:
      • Parallel to development.
    • Who:
      • Developer .
  • 7. How?
    • Tests are ideally written along with new code (and even before the new code).
    • Test-driven development:
      • Write test first.
      • Fill in the implementation untill test pas.
      • Rinse and repeat.
  • 8. Running Unit Tests
    • Automate so you don’t have to explicitly run tests.
    • Many testing frameworks can run tests every time you build.
    • Compiler checks SYNTAX . UnitTest check SEMANTICS
  • 9. OCUnit A Unit Testing framework for iOS
  • 10. History
    • 1998 - Written by Sen:te.
      • Objective C becomes onr of the first language to benefit from this approach of testing.
    • 2002 –Presented at WWDC.
    • 2005 – Apple decided to integrate it in Xcode 2.1.
    • 2008 – Apple actually integrated OCUnit in iPhone sdk 2.2
  • 11.
    • SenTestCases is abstract test superclass
    • Automatically runs methods thath begin with “test”
    • Macros for asserting conditions during tests.
    OCUnit
  • 12. Asserts Macros
  • 13. Example #import <SenTestingKit/SenTestingKit.h> #import <UIKit/UIKit.h> @class Person; @interface Person TestClass : SenTestCase { Person *personObj; //create the reference of the class to be tested } @end
  • 14. Example #import &quot;PersonTestClass.h&quot; #import &quot;Person.h&quot; @implementation PersonTestClass -(void)testCreatePerson { personObj= [[Person alloc] init]; STAssertNotNil (personObj, @&quot;A Person Object was never created&quot;); } @end
  • 15. DEMO A Unit Testing framework for iOS

×