Introduction to Unit Tests and TDD
Upcoming SlideShare
Loading in...5
×
 

Introduction to Unit Tests and TDD

on

  • 814 views

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

Statistics

Views

Total Views
814
Views on SlideShare
458
Embed Views
356

Actions

Likes
0
Downloads
6
Comments
0

3 Embeds 356

https://techblog.betclicgroup.com 347
http://cloud.feedly.com 8
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to Unit Tests and TDD Introduction to Unit Tests and TDD Presentation Transcript

  • Introduction to Unit Tests & TDD
  • UNIT TEST IN AN AGILE CONTEXT Agile XP UT 2
  • 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
  • INITIAL REACTIONS 4
  • BENEFITS • Higher quality (less bug) • Living documentation • Well-crafted code • Easier refactoring • Automatic regression harness 5
  • HOW UNIT TEST FRAMEWORKS WORK Unit test Runner .exe My Code My unit test code Unit Test Common Lib Test Results Code Coverage 6
  • 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
  • THE TESTS ARE THE SPECS *.doc files can’t prove software works ! 8
  • LIMITATION • 100 % code coverage impossible to reach • Impossible to catch all errors 9
  • UNIT TEST OR INTEGRATION TEST ? Too often we try to write unmaintainable integration tests UT IT UT 10
  • UNIT TEST VS. DATA BASE • Isolate data access with an interface 11
  • 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
  • TOOLS 13
  • .NET UNIT TESTING FRAMEWORKS 14
  • • Visual studio default interface MS TEST TOOLS • ReSharper 15
  • MOCKING FRAMEWORK: MOQ • Dynamically implement a interface • Test 16
  • 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
  • MORE TEST FIRST TECHNIQUES • ATDD - Acceptance test driven development Test written in a business language with a wiki • BDD Behavior Driven Development 18
  • CONCLUSION Everyone must be involved ! 19
  • 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
  • FIND OUT MORE • On https://techblog.betclicgroup.com/
  • 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.