Your SlideShare is downloading. ×
Introduction to Unit Tests and TDD
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

Introduction to Unit Tests and TDD

666
views

Published on

Discover why unit testing is such an important practice in software development and learn about Test Driven Development, mocking and other code testing practices in .Net

Discover why unit testing is such an important practice in software development and learn about Test Driven Development, mocking and other code testing practices in .Net

Published in: Technology, Education

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
666
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
7
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. Introduction to Unit Tests & TDD
  • 2. UNIT TEST IN AN AGILE CONTEXT Agile XP UT 2
  • 3. DEFINITION A unit test confirms functionality of a small unit of functionality or component in a larger system • • • • Written by developers isolate piece of code No use of database or external ressources Find problems early in dev cycle 3
  • 4. INITIAL REACTIONS 4
  • 5. BENEFITS • Higher quality (less bug) • Living documentation • Well-crafted code • Easier refactoring • Automatic regression harness 5
  • 6. HOW UNIT TEST FRAMEWORKS WORK Unit test Runner .exe My Code My unit test code Unit Test Common Lib Test Results Code Coverage 6
  • 7. TEST DRIVEN DEVELOPMENT 1. Create a falling test  Red 2. Make the test pass Green 3. Refactor  Improve the internal implementation without changing the external contract or behavior 7
  • 8. THE TESTS ARE THE SPECS *.doc files can’t prove software works ! 8
  • 9. LIMITATION • 100 % code coverage impossible to reach • Impossible to catch all errors 9
  • 10. UNIT TEST OR INTEGRATION TEST ? Too often we try to write unmaintainable integration tests UT IT UT 10
  • 11. UNIT TEST VS. DATA BASE • Isolate data access with an interface 11
  • 12. UNIT TEST VS. PROVIDERS Critical for teams using third-parties. • Unit Test to simulate provider calls • UnitTest unit to send data to providers If the provider updates its interface  test fails 12
  • 13. TOOLS 13
  • 14. .NET UNIT TESTING FRAMEWORKS 14
  • 15. • Visual studio default interface MS TEST TOOLS • ReSharper 15
  • 16. MOCKING FRAMEWORK: MOQ • Dynamically implement a interface • Test 16
  • 17. BEST PRACTICES • New projects have to include unit test • Legacy code : when a bug is raised, write a UT that fails, fix the bug and the UT is successful. 17
  • 18. MORE TEST FIRST TECHNIQUES • ATDD - Acceptance test driven development Test written in a business language with a wiki • BDD Behavior Driven Development 18
  • 19. CONCLUSION Everyone must be involved ! 19
  • 20. REFERENCES • http://blog.octo.com/quels-sont-les-types-de-tests-quel%E2%80%99on-utilise-sur-un-projet-agile/ • http://googletesting.blogspot.fr/ • http://weblogs.asp.net/garrypilkington/archive/2010/02/21/setting-upioc-with-mvc-quickly.aspx 20
  • 21. FIND OUT MORE • On https://techblog.betclicgroup.com/
  • 22. ABOUT BETCLIC • • • Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio comprising various complementary international brands: Betclic, Everest Gaming, bet-athome.com, Expekt… Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association). Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players.