Your SlideShare is downloading. ×
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
Mockito (JUG Latvia)
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

Mockito (JUG Latvia)

1,607

Published on

Published in: Technology, Self Improvement
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,607
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
67
Comments
0
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. Mockito JUG Latvia Denis Udod
  • 2. Mochito vs Mockito Mochito Recipe: 1/12 liter Dark Rum 3 cl Lemon Juice 1/2 handful Mint 1/12 liter Club Soda 8 drops Angostura Bitters
  • 3. Mochito vs Mockito Mochito Recipe: 1/12 liter Dark Rum 3 cl Lemon Juice 1/2 handful Mint 1/12 liter Club Soda 8 drops Angostura Bitters Mockito Recipe: Java Unit testing Mock object
  • 4. Mochito vs. Mockito Mochito Recipe: 1/12 liter Dark Rum 3 cl Lemon Juice 1/2 handful Mint 1/12 liter Club Soda 8 drops Angostura Bitters Mockito Recipe: Java Unit testing Mock object What is the difference?
  • 5. Mockito: Why drink it? Q: What is unit testing? Q: What is a mock-objects? Q: Why do we mock-objects?
  • 6. Unit testing - What's the point? Write simple test for each class method.
  • 7. Unit testing - What's the point? Write simple test for each class method.
  • 8. Unit testing - What's the point? Write simple test for each class method.
  • 9. Unit testing - What's the point? Write simple test for each class method. • simple • fast • independent from "any" (database, network, filesystem)
  • 10. Mock object - What's the point? Simulate the behavior of complex, real(non-mock) objects. • Useful when a real object is impractical or impossible to incorporate into a unit test.
  • 11. Mock object - What's the point? Example - service object supplies non-deterministic results:
  • 12. Mock object - What's the point? Example - service object supplies non-deterministic results:
  • 13. Mockito: Why drink it? • Mockito is a mocking framework that tastes really well. • It lets you write beautiful tests with clean & simple API. • Mockito doesn't give you hangover.
  • 14. Mockito: Why drink it? Syntax • Let’s keep it simple • No Strings for methods. • No anonymous inner classes. • Painless refactoring. Renaming a method should not break my tests.
  • 15. Mockito: How to drink it? 1. Download from http://mockito.org  2. Add to project. 3. And have fun
  • 16. Mockito: How to drink it? Create mock object:
  • 17. Mockito: How to drink it? Create mock object:
  • 18. Mockito: How to drink it? Create mock object:
  • 19. Mockito: How to drink it? How about returned values?
  • 20. Mockito: How to drink it? How about returned values?
  • 21. Mockito: How to drink it? Check method invocations
  • 22. Mockito: How to drink it? Check method invocations
  • 23. Mockito: How to drink it? Check method invocations
  • 24. Mockito: How to drink it? Check method invocations
  • 25. Mockito: How to drink it? Check method invocations
  • 26. Mockito: How to drink it? Spying on real object:
  • 27. Mockito: Hangover? Limitation: • needs java 1.5+ • Cannot mock final class • Cannot mock static, final methods • Cannot mock equals(),hashCode() metods • Cannot mock private metods • Cannot verify toString()
  • 28. Mockito Who is your bartender? Mockito is served to you by Szczepan Faber and friends. www.mockito.org

×