SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
FeaturesAndMotivations - mockito - Project Hosting on Google Code                      http://code.google.com/p/mockito/wiki/FeaturesAndMotivations


                                                                                                                          My favorites ▼ | Sign in


                    mockito
                    simpler & better mocking

           Project Home       Downloads       Wiki     Issues       Source

          Search                        for


           FeaturesAndMotivations
                                                                                                           Updated Oct 07, 2010 by
         Java mocking is dominated by expect-run-verify libraries like EasyMock or jMock.                  szcze...@gmail.com
         Mockito offers simpler and more intuitive approach: you ask questions about interactions
         after execution. Using mockito, you can verify what you want. Using expect-run-verify
         libraries you are often forced to look after irrelevant interactions.

         No expect-run-verify also means that Mockito mocks are often ready without expensive setup upfront. They aim to be
         transparent and let the developer to focus on testing selected behavior rather than absorb attention.

         Mockito has very slim API, almost no time is needed to start mocking. There is only one kind of mock, there is only one way of
         creating mocks. Just remember that stubbing goes before execution, verifications of interactions go afterwards. You'll soon
         notice how natural is that kind of mocking when TDD-ing java code.

         Mockito has similar syntax to EasyMock, therefore you can refactor safely. Mockito doesn't understand the notion of
         'expectation'. There is only stubbing and verifications.

         Mockito implements what Gerard Meszaros calls a Test Spy.

         Some other features:

                 Mocks concrete classes as well as interfaces
                 Little annotation syntax sugar - @Mock
                 Verification errors are clean - click on stack trace to see failed verification in test; click on exception's cause to navigate to
                 actual interaction in code. Stack trace is always clean.
                 Allows flexible verification in order (e.g: verify in order what you want, not every single interaction)
                 Supports exact-number-of-times and at-least-once verification
                 Flexible verification or stubbing using argument matchers (anyObject(), anyString() or refEq() for reflection-based equality
                 matching)
                 Allows creating custom argument matchers or using existing hamcrest matchers

         Distribution:

                 Single-jar distribution includes cglib, objenesis and source code
                 Zip distribution contains all jars, javadoc and source code



         ►   Sign in to add a comment




                                                ©2010 Google - Terms - Privacy - Project Hosting Help
                                                           Powered by Google Project Hosting




1 of 1                                                                                                                             3/1/2011 5:13 PM

Weitere ähnliche Inhalte

Andere mochten auch

P4《明星作家》第一期
P4《明星作家》第一期P4《明星作家》第一期
P4《明星作家》第一期rssstarwriter
 
Przygoda KsiężNiczki B1
Przygoda KsiężNiczki B1Przygoda KsiężNiczki B1
Przygoda KsiężNiczki B1studium
 
MOTIVATION AS A FACTOR IN LANGUAGE LEARNING
MOTIVATION AS A FACTOR IN LANGUAGE LEARNINGMOTIVATION AS A FACTOR IN LANGUAGE LEARNING
MOTIVATION AS A FACTOR IN LANGUAGE LEARNINGEuphie Clyne
 
University References
University ReferencesUniversity References
University ReferencesNino Krizaj
 
Alemanha - Integrante da União Europeia
Alemanha - Integrante da União EuropeiaAlemanha - Integrante da União Europeia
Alemanha - Integrante da União EuropeiaLucas Cechinel
 
Tens Pads Placement
Tens Pads PlacementTens Pads Placement
Tens Pads PlacementSpooky2 Rife
 
Intro to Mocking - DjangoCon 2015
Intro to Mocking - DjangoCon 2015Intro to Mocking - DjangoCon 2015
Intro to Mocking - DjangoCon 2015Excella
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureDmitry Buzdin
 

Andere mochten auch (13)

777
777777
777
 
P4《明星作家》第一期
P4《明星作家》第一期P4《明星作家》第一期
P4《明星作家》第一期
 
GreenMash–SCM V2
GreenMash–SCM V2GreenMash–SCM V2
GreenMash–SCM V2
 
Przygoda KsiężNiczki B1
Przygoda KsiężNiczki B1Przygoda KsiężNiczki B1
Przygoda KsiężNiczki B1
 
MOTIVATION AS A FACTOR IN LANGUAGE LEARNING
MOTIVATION AS A FACTOR IN LANGUAGE LEARNINGMOTIVATION AS A FACTOR IN LANGUAGE LEARNING
MOTIVATION AS A FACTOR IN LANGUAGE LEARNING
 
University References
University ReferencesUniversity References
University References
 
Alemanha - Integrante da União Europeia
Alemanha - Integrante da União EuropeiaAlemanha - Integrante da União Europeia
Alemanha - Integrante da União Europeia
 
Tens Pads Placement
Tens Pads PlacementTens Pads Placement
Tens Pads Placement
 
Intro to Mocking - DjangoCon 2015
Intro to Mocking - DjangoCon 2015Intro to Mocking - DjangoCon 2015
Intro to Mocking - DjangoCon 2015
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
 
La geosfera
La geosferaLa geosfera
La geosfera
 
O Passe
O PasseO Passe
O Passe
 
Leef in god se teenwoordigheid5
Leef in god se teenwoordigheid5Leef in god se teenwoordigheid5
Leef in god se teenwoordigheid5
 

Ähnlich wie Mockito Features And Motivations - Simpler And Better Java Mocking

Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsNuno Caneco
 
Prototyping user interactions in web apps
Prototyping user interactions in web appsPrototyping user interactions in web apps
Prototyping user interactions in web appsPatrick NDJIENTCHEU
 
Battle of The Mocking Frameworks
Battle of The Mocking FrameworksBattle of The Mocking Frameworks
Battle of The Mocking FrameworksDror Helper
 
Blast Mojo Overview
Blast Mojo OverviewBlast Mojo Overview
Blast Mojo Overviewloyalchow
 
Your Future HTML: The Evolution of Site Design with Web Components
Your Future HTML: The Evolution of Site Design with Web ComponentsYour Future HTML: The Evolution of Site Design with Web Components
Your Future HTML: The Evolution of Site Design with Web ComponentsKen Tabor
 
Dependency Injection in .NET applications
Dependency Injection in .NET applicationsDependency Injection in .NET applications
Dependency Injection in .NET applicationsBabak Naffas
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkSt. Petersburg College
 
Javascript framework and backbone
Javascript framework and backboneJavascript framework and backbone
Javascript framework and backboneDaniel Lv
 
Shift Left Mobile Application Testing
Shift Left Mobile Application TestingShift Left Mobile Application Testing
Shift Left Mobile Application TestingJosiah Renaudin
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadRuss Fustino
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfBruceLee275640
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionFernando Cejas
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Editionpenanochizzo
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScriptRob Scaduto
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureZachary Klein
 
Open Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C WidgetsOpen Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C Widgetsscottw
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Heiko Behrens
 
Introduction to Protractor - Habilelabs
Introduction to Protractor - HabilelabsIntroduction to Protractor - Habilelabs
Introduction to Protractor - HabilelabsHabilelabs
 

Ähnlich wie Mockito Features And Motivations - Simpler And Better Java Mocking (20)

Mock with Mockito
Mock with MockitoMock with Mockito
Mock with Mockito
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystems
 
Prototyping user interactions in web apps
Prototyping user interactions in web appsPrototyping user interactions in web apps
Prototyping user interactions in web apps
 
Battle of The Mocking Frameworks
Battle of The Mocking FrameworksBattle of The Mocking Frameworks
Battle of The Mocking Frameworks
 
Blast Mojo Overview
Blast Mojo OverviewBlast Mojo Overview
Blast Mojo Overview
 
Your Future HTML: The Evolution of Site Design with Web Components
Your Future HTML: The Evolution of Site Design with Web ComponentsYour Future HTML: The Evolution of Site Design with Web Components
Your Future HTML: The Evolution of Site Design with Web Components
 
Dependency Injection in .NET applications
Dependency Injection in .NET applicationsDependency Injection in .NET applications
Dependency Injection in .NET applications
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
 
Community Tour Bologna
Community Tour BolognaCommunity Tour Bologna
Community Tour Bologna
 
Javascript framework and backbone
Javascript framework and backboneJavascript framework and backbone
Javascript framework and backbone
 
Shift Left Mobile Application Testing
Shift Left Mobile Application TestingShift Left Mobile Application Testing
Shift Left Mobile Application Testing
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) upload
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdf
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Edition
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Edition
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScript
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro Future
 
Open Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C WidgetsOpen Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C Widgets
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
 
Introduction to Protractor - Habilelabs
Introduction to Protractor - HabilelabsIntroduction to Protractor - Habilelabs
Introduction to Protractor - Habilelabs
 

Mockito Features And Motivations - Simpler And Better Java Mocking

  • 1. FeaturesAndMotivations - mockito - Project Hosting on Google Code http://code.google.com/p/mockito/wiki/FeaturesAndMotivations My favorites ▼ | Sign in mockito simpler & better mocking Project Home Downloads Wiki Issues Source Search for FeaturesAndMotivations Updated Oct 07, 2010 by Java mocking is dominated by expect-run-verify libraries like EasyMock or jMock. szcze...@gmail.com Mockito offers simpler and more intuitive approach: you ask questions about interactions after execution. Using mockito, you can verify what you want. Using expect-run-verify libraries you are often forced to look after irrelevant interactions. No expect-run-verify also means that Mockito mocks are often ready without expensive setup upfront. They aim to be transparent and let the developer to focus on testing selected behavior rather than absorb attention. Mockito has very slim API, almost no time is needed to start mocking. There is only one kind of mock, there is only one way of creating mocks. Just remember that stubbing goes before execution, verifications of interactions go afterwards. You'll soon notice how natural is that kind of mocking when TDD-ing java code. Mockito has similar syntax to EasyMock, therefore you can refactor safely. Mockito doesn't understand the notion of 'expectation'. There is only stubbing and verifications. Mockito implements what Gerard Meszaros calls a Test Spy. Some other features: Mocks concrete classes as well as interfaces Little annotation syntax sugar - @Mock Verification errors are clean - click on stack trace to see failed verification in test; click on exception's cause to navigate to actual interaction in code. Stack trace is always clean. Allows flexible verification in order (e.g: verify in order what you want, not every single interaction) Supports exact-number-of-times and at-least-once verification Flexible verification or stubbing using argument matchers (anyObject(), anyString() or refEq() for reflection-based equality matching) Allows creating custom argument matchers or using existing hamcrest matchers Distribution: Single-jar distribution includes cglib, objenesis and source code Zip distribution contains all jars, javadoc and source code ► Sign in to add a comment ©2010 Google - Terms - Privacy - Project Hosting Help Powered by Google Project Hosting 1 of 1 3/1/2011 5:13 PM