SlideShare a Scribd company logo
Unit Testing framework in iOS
What? What is Unit-Testing? Available Unit Testing frameworks for iOS. Basics of OCUnit Testing.
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.
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.
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
When and Who? When: Parallel  to development. Who: Developer .
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.
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
OCUnit A Unit Testing framework for iOS
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
SenTestCases  is abstract test superclass Automatically runs methods thath begin with “test” Macros for asserting conditions during tests. OCUnit
Asserts Macros
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
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
DEMO A Unit Testing framework for iOS

More Related Content

PPTX
An Introduction to Dependency Inversion Principle
PPTX
Dependency Inversion Principle
PDF
Functional Tests Automation with Robot Framework
PDF
How we test the code analyzer
PPTX
Dependency Inversion Principle
PDF
Open Source Software Testing Tools
PPTX
Unit Testing Android Applications
PDF
Introduction to Robot Framework
An Introduction to Dependency Inversion Principle
Dependency Inversion Principle
Functional Tests Automation with Robot Framework
How we test the code analyzer
Dependency Inversion Principle
Open Source Software Testing Tools
Unit Testing Android Applications
Introduction to Robot Framework

What's hot (20)

PDF
How we test the code analyzer
PPTX
Dip(dependency inversion principle) presentation
PPTX
Php unit
PPT
Nunit
PDF
A journey with Target Platforms
PPTX
Unit Testing Using N Unit
PPTX
Dev fest2015androidunittestingbyoyewaleademolasao
PPTX
Robot framework Gowthami Goli
PDF
Acceptance Test Drive Development with Robot Framework
PPT
Unit testing
PPTX
AspectMock
PDF
Introduction to Robot Framework (external)
PDF
Barcamp Bangkhen :: Robot Framework
PPTX
#1 unit testing
ODP
Testing in Android: automatici, di integrazione, TDD e scenari avanzati
PPTX
Test Driven Development
PDF
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
PPTX
Unit testing with NUnit
PDF
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
How we test the code analyzer
Dip(dependency inversion principle) presentation
Php unit
Nunit
A journey with Target Platforms
Unit Testing Using N Unit
Dev fest2015androidunittestingbyoyewaleademolasao
Robot framework Gowthami Goli
Acceptance Test Drive Development with Robot Framework
Unit testing
AspectMock
Introduction to Robot Framework (external)
Barcamp Bangkhen :: Robot Framework
#1 unit testing
Testing in Android: automatici, di integrazione, TDD e scenari avanzati
Test Driven Development
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
Unit testing with NUnit
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
Ad

Viewers also liked (8)

PDF
MarCom World Wide Info
PPTX
Jdc colorado expansion presentation
PDF
Electric appliances
KEY
Aaf 9-15-10
PPSX
Basissheets inleiding sjaak1.1 met video's slideshow
PPTX
Apps for productivity talk
PPT
Women of Substance 09122010
PPTX
Big Data Analytics with Hadoop
MarCom World Wide Info
Jdc colorado expansion presentation
Electric appliances
Aaf 9-15-10
Basissheets inleiding sjaak1.1 met video's slideshow
Apps for productivity talk
Women of Substance 09122010
Big Data Analytics with Hadoop
Ad

Similar to Unit testing_pps (20)

PPT
Unit Testing in iOS
PDF
A Comprehensive Guide to Efficiently Writing and Implementing iOS Unit Tests.pdf
PDF
Unit Tesing in iOS
PPT
Nguyenvandungb seminar
PDF
Unit testing in xcode 8 with swift
PPT
Unit Testing in iOS - Ninjava Talk
PDF
Swift testing ftw
PDF
Beginning iOS unit testing
PDF
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
PPTX
Unit test
PDF
Test driven development
PDF
Automated Testing on iOS
PDF
Testing iOS applications
PDF
2013.02.02 지앤선 테크니컬 세미나 - iOS 테스팅 이야기(OSXDEV)
PDF
Test Driven iOS Development (TDD)
PPTX
Unit Testing and TDD 2017
PPT
Test Automation Principles
PDF
Unit testing, principles
PPTX
Skillwise Unit Testing
PPTX
Unit Testing in Java
Unit Testing in iOS
A Comprehensive Guide to Efficiently Writing and Implementing iOS Unit Tests.pdf
Unit Tesing in iOS
Nguyenvandungb seminar
Unit testing in xcode 8 with swift
Unit Testing in iOS - Ninjava Talk
Swift testing ftw
Beginning iOS unit testing
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit test
Test driven development
Automated Testing on iOS
Testing iOS applications
2013.02.02 지앤선 테크니컬 세미나 - iOS 테스팅 이야기(OSXDEV)
Test Driven iOS Development (TDD)
Unit Testing and TDD 2017
Test Automation Principles
Unit testing, principles
Skillwise Unit Testing
Unit Testing in Java

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
Teaching material agriculture food technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Spectroscopy.pptx food analysis technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Approach and Philosophy of On baking technology
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MYSQL Presentation for SQL database connectivity
Approach and Philosophy of On baking technology

Unit testing_pps

  • 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
  • 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