SlideShare une entreprise Scribd logo
1  sur  45
Dror Helper - http://blogs.microsoft.co.il/blogs/dhelper
Doron Peretz – http://twitter.com/doronp
Typemock Ltd.




                                                           Typemock™
Typemock™

 Typemock Isolator
 Established 2005, privately owned
 Thousands of customers (Fortune 500)
 Tens of thousands licenses sold




                                   Typemock™
Agenda
   Using TDD for Fun & Profit

   A day in the life of TDD developer

   Testing difficult scenarios

   Share the Pain!

                                         Typemock™
`




How to implement unit testing in your development team




                                                         Typemock™
Sounds Familiar?
20:00 – One bug left before release
20:01 - Done!
20:02 - Send version to QA, call wife
20:05 - On the way to the elevator.
          QA: It doesn’t work!

22:50 - What have I done?!

                                        Typemock™
Unit testing for Fun & Profit
 Short Overview: Unit Test, TDD
 Why unit test?
 Things you thought you knew
 Tools you need to know about




                                   Typemock™
Overview


What is Unit Test?
   Verifies an atomic piece of code
   Tests one specific behavior
   Each Test is autonomous

[TestMethod]
public void CheckPassword_ValidUser_ReturnTrue()
{
   bool result = CheckPassword(“user”, “pass”);

    Assert.IsTrue(result);
}
                                             Typemock™
Overview


Test Driven Development
                          Write
                          new
                          Test


                                           Run
           Refactor
                                          Tests




                   Run            Write
                  Tests           code

                                                  Typemock™
Why Unit Test?


Why not use Unit Test
Testing is for QA

Time = Cost

Integration Testing find more bugs
Manual Testing find more bugs

It’s like writing the code twice
                                     Typemock™
Why Unit Test?


Is TDD a Waste of Time?
              Time taken to code a feature
140%                         135%
             120%                                    125%
120%                                       115%

100%
80%
60%
40%
20%
 0%
       IBM: Drivers    MS: Windows     MS: MSN    MS: VS
                      WithoutTDD     Using TDD
                                                       Typemock™
Why Unit Test?


Is TDD a Waste of Time?
                Using Test Driven Design
140%
120%
100%
80%
              61%
60%
                            38%
40%
                                            24%
20%                                                          9%
 0%
       IBM: Drivers   MS: Windows     MS: MSN          MS: VS
 Major quality improvement for minor time investment
         Time To Code Feature       Defect density of team
                                                              Typemock™
Why Unit Test?


So Why Unit Test?
                                            Where does it hurt?
                    100%                                                                          10
                                            The pain is here!             This is too late…       9

                    80%                                                                           8
% defects created




                                                                                                  7




                                                                                                       Thousand $s
                    60%                                                                           6

                                                                                                  5

                    40%                                                                           4

                                                                                                  3

                    20%                                                                           2

                                                                                                  1

                     0%                                                                           0
                           Requirements    Coding      Integration        Testing
                                                                                            Typemock™
                                                                                        Support

                                    % of Defects Introduced          Cost to Fix a Defect
Misconceptions


TDD is not about testing
   TDD is about design and development

   By testing first you design your code




                                            Typemock™
Misconceptions

Unit Tests are written by
developers!
 Increase confidence in code
 Fearlessly change your code
 Document requirements
 Discover usability issues early




                                           Typemock™
Misconceptions
Unit Tests are Not
Integration
   Unit tests should be:
     Small
     Atomic
     Test a single functional unit
     Isolated!


   Integration tests are used to test system
    wide functionality

                                                 Typemock™
Tools


Unit Testing Frameworks
 Consensus – NUnit
 Integrated – MSTest
 New kid on the block – XUnit
 Performance oriented – Zenebug
 Meta framework- Gallio (MBUnit)




                                    Typemock™
Tools


Mocking / Isolation
   Each unit test MUST be isolated

   How do we test business logic without
    Database calls?




                                        Typemock™
Tools


Isolation – Mocking frameowrks
Open Source:
 NMock2
 Moq
 Rhino Mocks


Commercial (costs money but worth it)
 Typemock Isolator


                                        Typemock™
Tools


Visual Studio Integration
Refactoring
 Code Rush
 R#


Unit test runners
 TestDriven.NET
 R# Test Runner


                            Typemock™
Tools


Continuous Integration                         Build Server
                                                (TeamCity)
                                What’s new?

     Commit
                               There you go

              Source Control
                  (SVN)

                                              We automatically got
                                              •Error reports & logs
                                              •New version installer
                                              •Help files
                                              •More…



                         Build Agents                Typemock™
                         (FinalBuilder)
Tools


Continuous Integration
                                     Computer
                                     Says NO!
Build Automation Tools
 NAnt
 MSBuild
 FinalBuilder

CI Servers
 CCnet
 TeamCity
 Team System / Team Foundation Server
 FinalBuilder Server
                                         Typemock™
`




Examples, demonstrations & fun




                                     Typemock™
A Day in the Life of a
TDD'er
 The tools we use at Typemock
 Writing some code
 OK, who broke the Build?!
 Too much spare time…




                                 Typemock™
Our Tools


The Tools We Use
 Unit testing – MSTest/NUnit
 Build automation – FinalBuilder




                                    Typemock™
Our Tools


Build Script at a Glance




                           Typemock™
Our Tools


The Tools We Use
 Unit testing – MSTest/NUnit
 Build automation – FinalBuilder
 Continuous Integration – TeamCity




                                      Typemock™
Our Tools


TeamCity at a Glance




                       Typemock™
Our Tools


The Tools We Use
 Unit testing – MSTest/NUnit
 Build automation – FinalBuilder
 Continuous Integration – TeamCity
 Integrated tools – R#, TestDriven.NET
 Isolation Framework – Isolator (surprise!)
 Build Bunny!




                                         Typemock™
Write Code


Writing Some Code
   We begin with a clean slate

                          Write
                         new test


                                             Run
         Refactor
                                            tests




               Run All              Write
                tests               code
                                                    Typemock™
Write Code


Writing Some Code
   An exercise in futility…

                           Write
                          new test


                                              Run
          Refactor
                                             tests




                Run all              Write
                 tests               code
                                                     Typemock™
Write Code


Writing Some Code
   Now we get our hands dirty
                         Write
                         new
                         Test


                                          Run
         Refactor
                                         tests




               Run all           Write
                tests            code
                                                 Typemock™
Write Code


Writing Some Code
   Make sure everything’s fine…
                         Write
                         new
                         Test


                                          Run
         Refactor
                                         tests




               Run all           Write
                tests            code
                                                 Typemock™
Write Code


Writing Some Code
   … and make it perform/look better

                          Write
                         new test


                                             Run
         Refactor
                                            tests




               Run all              Write
                tests               code
                                                    Typemock™
Write Code


Writing Some Code
   Lets take her out for another spin…
                         Write
                         new
                         Test


                                          Run
         Refactor
                                         tests




               Run all           Write
                tests            code
                                                 Typemock™
Broken Build


OK, Who Broke the Build?
   Something went horribly wrong!
     And it’s easy to find who to blame 
     But it’s easy to find out what happened


   Why is this important?
     The project heartbeat
     Healthy build == easy to release



                                                Typemock™
Spare Time


Too Much Spare Time
 The foosball table
 The build bunny
 The Shooting of The Zombies
 Helping children with computer skills




                                          Typemock™
Not everything in life is easy…




                                  Typemock™
Examples from the real
world
 Hard to unit test scenarios
 How to solve this problem
 Examples




                                Typemock™
Difficult scenarios to Unit
Test
 Client – server architecture
 Databases
 Legacy Code
 Closed Object Models
  (Sharepoint, Silverlight)
 GUI interaction




                                 Typemock™
Possible solutions
   First - better understand the problem

 Design for Testability
 Refactoring for Testability
 Reflection
 Mocks / Isolation


   Last resort - Integration tests instead
                                              Typemock™
Example Unit Testing WCF
Client
Class: WCF Client
Method: string GetSourceList(string source);

Problem: Server connection is not possible




                                       Typemock™
Unit Testing WCF Client
Overview:



 DataProviderClient

                                       DataProviderServer




 ISourceListProvider   GetSourceList



                                               Typemock™
Unit Testing Windows
Forms

                                              Database


Registration Form          Business
                            Logic




                    Registration Controller      Typemock™
Share The Pain
   Your unit testing stories

   Q&A




                                Typemock™
Thank you
Want to learn more?

Read about Test Driven Development &
  Isolation at the Typemock Insiders blog

Follow up on twitter.com/Typemock

Take a card and drop us an email!
                                       Typemock™

Contenu connexe

Tendances

Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove
 
Is this how you hate unit testing?
Is this how you hate unit testing?Is this how you hate unit testing?
Is this how you hate unit testing?
Steven Mak
 
Java Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionJava Unit Test and Coverage Introduction
Java Unit Test and Coverage Introduction
Alex Su
 
Unit Testing Guidelines
Unit Testing GuidelinesUnit Testing Guidelines
Unit Testing Guidelines
Joel Hooks
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
Richard Paul
 

Tendances (20)

Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit Testing Your Application
Unit Testing Your ApplicationUnit Testing Your Application
Unit Testing Your Application
 
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
 
Unit testing
Unit testingUnit testing
Unit testing
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Unit Testing (C#)
Unit Testing (C#)Unit Testing (C#)
Unit Testing (C#)
 
Is this how you hate unit testing?
Is this how you hate unit testing?Is this how you hate unit testing?
Is this how you hate unit testing?
 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit Testing
 
Java Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionJava Unit Test and Coverage Introduction
Java Unit Test and Coverage Introduction
 
Unit test
Unit testUnit test
Unit test
 
Unit testing
Unit testing Unit testing
Unit testing
 
Unit Testing Guidelines
Unit Testing GuidelinesUnit Testing Guidelines
Unit Testing Guidelines
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 

En vedette

Software development slides
Software development slidesSoftware development slides
Software development slides
iarthur
 
Exactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaExactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in Kostroma
Iosif Itkin
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
Heo Seungwook
 

En vedette (15)

Software development slides
Software development slidesSoftware development slides
Software development slides
 
구글테스트
구글테스트구글테스트
구글테스트
 
Improve Communications in the Workplace
Improve Communications in the WorkplaceImprove Communications in the Workplace
Improve Communications in the Workplace
 
How To Improve Communication Skill
How To Improve  Communication  SkillHow To Improve  Communication  Skill
How To Improve Communication Skill
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
Exactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaExactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in Kostroma
 
Rundeck's History and Future
Rundeck's History and FutureRundeck's History and Future
Rundeck's History and Future
 
How do I do DevOps when all I have is Ops?
How do I do DevOps when all I have is Ops?How do I do DevOps when all I have is Ops?
How do I do DevOps when all I have is Ops?
 
How will DevOps benefit enterprise?
How will DevOps benefit enterprise? How will DevOps benefit enterprise?
How will DevOps benefit enterprise?
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
 
KGC2010 - 낡은 코드에 단위테스트 넣기
KGC2010 - 낡은 코드에 단위테스트 넣기KGC2010 - 낡은 코드에 단위테스트 넣기
KGC2010 - 낡은 코드에 단위테스트 넣기
 
Behavior Driven Development Pros and Cons
Behavior Driven Development Pros and ConsBehavior Driven Development Pros and Cons
Behavior Driven Development Pros and Cons
 
Product Teardown for SaaS companies at #SaaSx4
Product Teardown for SaaS companies at #SaaSx4Product Teardown for SaaS companies at #SaaSx4
Product Teardown for SaaS companies at #SaaSx4
 
10 Tips for Making Beautiful Slideshow Presentations by www.visuali.se
10 Tips for Making Beautiful Slideshow Presentations by www.visuali.se10 Tips for Making Beautiful Slideshow Presentations by www.visuali.se
10 Tips for Making Beautiful Slideshow Presentations by www.visuali.se
 
8 Tips for an Awesome Powerpoint Presentation
8 Tips for an Awesome Powerpoint Presentation8 Tips for an Awesome Powerpoint Presentation
8 Tips for an Awesome Powerpoint Presentation
 

Similaire à Benefit From Unit Testing In The Real World

Gabriele Lana: Testing Web Applications
Gabriele Lana: Testing Web ApplicationsGabriele Lana: Testing Web Applications
Gabriele Lana: Testing Web Applications
Francesco Fullone
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
Steve Lange
 
Adopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy ContextAdopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy Context
Xavier Warzee
 
Software Architecture: Test Case Writing
Software Architecture: Test Case WritingSoftware Architecture: Test Case Writing
Software Architecture: Test Case Writing
Sitdhibong Laokok
 

Similaire à Benefit From Unit Testing In The Real World (20)

Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
TDD sharevison team
TDD sharevison teamTDD sharevison team
TDD sharevison team
 
Gabriele Lana: Testing Web Applications
Gabriele Lana: Testing Web ApplicationsGabriele Lana: Testing Web Applications
Gabriele Lana: Testing Web Applications
 
Постоянное тестирование интеграции
Постоянное тестирование интеграцииПостоянное тестирование интеграции
Постоянное тестирование интеграции
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
 
Coding Naked
Coding NakedCoding Naked
Coding Naked
 
Visual Studio 2010 Testing & Lab Management Tools
Visual Studio 2010 Testing & Lab Management ToolsVisual Studio 2010 Testing & Lab Management Tools
Visual Studio 2010 Testing & Lab Management Tools
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
 
Adopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy ContextAdopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy Context
 
QA Fest 2018. Ярослав Пернеровский. Test Automation Pyramid, how it ruins you...
QA Fest 2018. Ярослав Пернеровский. Test Automation Pyramid, how it ruins you...QA Fest 2018. Ярослав Пернеровский. Test Automation Pyramid, how it ruins you...
QA Fest 2018. Ярослав Пернеровский. Test Automation Pyramid, how it ruins you...
 
Dependency Injection in .NET applications
Dependency Injection in .NET applicationsDependency Injection in .NET applications
Dependency Injection in .NET applications
 
Logic Atollic True Verifier
Logic Atollic True VerifierLogic Atollic True Verifier
Logic Atollic True Verifier
 
Test-driven Development Practices in White Box Test Automation
Test-driven Development Practices in White Box Test AutomationTest-driven Development Practices in White Box Test Automation
Test-driven Development Practices in White Box Test Automation
 
AspectMock
AspectMockAspectMock
AspectMock
 
Just Java2007 - Daniel Wildt - Tools For Java Test Automation
Just Java2007 - Daniel Wildt - Tools For Java Test AutomationJust Java2007 - Daniel Wildt - Tools For Java Test Automation
Just Java2007 - Daniel Wildt - Tools For Java Test Automation
 
Software Architecture: Test Case Writing
Software Architecture: Test Case WritingSoftware Architecture: Test Case Writing
Software Architecture: Test Case Writing
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable Code
 
Unit Tests with Microsoft Fakes
Unit Tests with Microsoft FakesUnit Tests with Microsoft Fakes
Unit Tests with Microsoft Fakes
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
 
Continuous Change-Driven Build Verification
Continuous Change-Driven Build Verification  Continuous Change-Driven Build Verification
Continuous Change-Driven Build Verification
 

Plus de Dror Helper

Plus de Dror Helper (20)

Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
 
Debugging with visual studio beyond 'F5'
Debugging with visual studio beyond 'F5'Debugging with visual studio beyond 'F5'
Debugging with visual studio beyond 'F5'
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
A software developer guide to working with aws
A software developer guide to working with awsA software developer guide to working with aws
A software developer guide to working with aws
 
The secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you aboutThe secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you about
 
The role of the architect in agile
The role of the architect in agileThe role of the architect in agile
The role of the architect in agile
 
Harnessing the power of aws using dot net core
Harnessing the power of aws using dot net coreHarnessing the power of aws using dot net core
Harnessing the power of aws using dot net core
 
Developing multi-platform microservices using .NET core
 Developing multi-platform microservices using .NET core Developing multi-platform microservices using .NET core
Developing multi-platform microservices using .NET core
 
Harnessing the power of aws using dot net
Harnessing the power of aws using dot netHarnessing the power of aws using dot net
Harnessing the power of aws using dot net
 
Secret unit testing tools no one ever told you about
Secret unit testing tools no one ever told you aboutSecret unit testing tools no one ever told you about
Secret unit testing tools no one ever told you about
 
C++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyC++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the ugly
 
Working with c++ legacy code
Working with c++ legacy codeWorking with c++ legacy code
Working with c++ legacy code
 
Visual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should knowVisual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should know
 
Secret unit testing tools
Secret unit testing toolsSecret unit testing tools
Secret unit testing tools
 
Electronics 101 for software developers
Electronics 101 for software developersElectronics 101 for software developers
Electronics 101 for software developers
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Who’s afraid of WinDbg
Who’s afraid of WinDbgWho’s afraid of WinDbg
Who’s afraid of WinDbg
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Benefit From Unit Testing In The Real World

  • 1. Dror Helper - http://blogs.microsoft.co.il/blogs/dhelper Doron Peretz – http://twitter.com/doronp Typemock Ltd. Typemock™
  • 2. Typemock™  Typemock Isolator  Established 2005, privately owned  Thousands of customers (Fortune 500)  Tens of thousands licenses sold Typemock™
  • 3. Agenda  Using TDD for Fun & Profit  A day in the life of TDD developer  Testing difficult scenarios  Share the Pain! Typemock™
  • 4. ` How to implement unit testing in your development team Typemock™
  • 5. Sounds Familiar? 20:00 – One bug left before release 20:01 - Done! 20:02 - Send version to QA, call wife 20:05 - On the way to the elevator. QA: It doesn’t work! 22:50 - What have I done?! Typemock™
  • 6. Unit testing for Fun & Profit  Short Overview: Unit Test, TDD  Why unit test?  Things you thought you knew  Tools you need to know about Typemock™
  • 7. Overview What is Unit Test?  Verifies an atomic piece of code  Tests one specific behavior  Each Test is autonomous [TestMethod] public void CheckPassword_ValidUser_ReturnTrue() { bool result = CheckPassword(“user”, “pass”); Assert.IsTrue(result); } Typemock™
  • 8. Overview Test Driven Development Write new Test Run Refactor Tests Run Write Tests code Typemock™
  • 9. Why Unit Test? Why not use Unit Test Testing is for QA Time = Cost Integration Testing find more bugs Manual Testing find more bugs It’s like writing the code twice Typemock™
  • 10. Why Unit Test? Is TDD a Waste of Time? Time taken to code a feature 140% 135% 120% 125% 120% 115% 100% 80% 60% 40% 20% 0% IBM: Drivers MS: Windows MS: MSN MS: VS WithoutTDD Using TDD Typemock™
  • 11. Why Unit Test? Is TDD a Waste of Time? Using Test Driven Design 140% 120% 100% 80% 61% 60% 38% 40% 24% 20% 9% 0% IBM: Drivers MS: Windows MS: MSN MS: VS Major quality improvement for minor time investment Time To Code Feature Defect density of team Typemock™
  • 12. Why Unit Test? So Why Unit Test? Where does it hurt? 100% 10 The pain is here! This is too late… 9 80% 8 % defects created 7 Thousand $s 60% 6 5 40% 4 3 20% 2 1 0% 0 Requirements Coding Integration Testing Typemock™ Support % of Defects Introduced Cost to Fix a Defect
  • 13. Misconceptions TDD is not about testing  TDD is about design and development  By testing first you design your code Typemock™
  • 14. Misconceptions Unit Tests are written by developers!  Increase confidence in code  Fearlessly change your code  Document requirements  Discover usability issues early Typemock™
  • 15. Misconceptions Unit Tests are Not Integration  Unit tests should be:  Small  Atomic  Test a single functional unit  Isolated!  Integration tests are used to test system wide functionality Typemock™
  • 16. Tools Unit Testing Frameworks  Consensus – NUnit  Integrated – MSTest  New kid on the block – XUnit  Performance oriented – Zenebug  Meta framework- Gallio (MBUnit) Typemock™
  • 17. Tools Mocking / Isolation  Each unit test MUST be isolated  How do we test business logic without Database calls? Typemock™
  • 18. Tools Isolation – Mocking frameowrks Open Source:  NMock2  Moq  Rhino Mocks Commercial (costs money but worth it)  Typemock Isolator Typemock™
  • 19. Tools Visual Studio Integration Refactoring  Code Rush  R# Unit test runners  TestDriven.NET  R# Test Runner Typemock™
  • 20. Tools Continuous Integration Build Server (TeamCity) What’s new? Commit There you go Source Control (SVN) We automatically got •Error reports & logs •New version installer •Help files •More… Build Agents Typemock™ (FinalBuilder)
  • 21. Tools Continuous Integration Computer Says NO! Build Automation Tools  NAnt  MSBuild  FinalBuilder CI Servers  CCnet  TeamCity  Team System / Team Foundation Server  FinalBuilder Server Typemock™
  • 22. ` Examples, demonstrations & fun Typemock™
  • 23. A Day in the Life of a TDD'er  The tools we use at Typemock  Writing some code  OK, who broke the Build?!  Too much spare time… Typemock™
  • 24. Our Tools The Tools We Use  Unit testing – MSTest/NUnit  Build automation – FinalBuilder Typemock™
  • 25. Our Tools Build Script at a Glance Typemock™
  • 26. Our Tools The Tools We Use  Unit testing – MSTest/NUnit  Build automation – FinalBuilder  Continuous Integration – TeamCity Typemock™
  • 27. Our Tools TeamCity at a Glance Typemock™
  • 28. Our Tools The Tools We Use  Unit testing – MSTest/NUnit  Build automation – FinalBuilder  Continuous Integration – TeamCity  Integrated tools – R#, TestDriven.NET  Isolation Framework – Isolator (surprise!)  Build Bunny! Typemock™
  • 29. Write Code Writing Some Code  We begin with a clean slate Write new test Run Refactor tests Run All Write tests code Typemock™
  • 30. Write Code Writing Some Code  An exercise in futility… Write new test Run Refactor tests Run all Write tests code Typemock™
  • 31. Write Code Writing Some Code  Now we get our hands dirty Write new Test Run Refactor tests Run all Write tests code Typemock™
  • 32. Write Code Writing Some Code  Make sure everything’s fine… Write new Test Run Refactor tests Run all Write tests code Typemock™
  • 33. Write Code Writing Some Code  … and make it perform/look better Write new test Run Refactor tests Run all Write tests code Typemock™
  • 34. Write Code Writing Some Code  Lets take her out for another spin… Write new Test Run Refactor tests Run all Write tests code Typemock™
  • 35. Broken Build OK, Who Broke the Build?  Something went horribly wrong!  And it’s easy to find who to blame   But it’s easy to find out what happened  Why is this important?  The project heartbeat  Healthy build == easy to release Typemock™
  • 36. Spare Time Too Much Spare Time  The foosball table  The build bunny  The Shooting of The Zombies  Helping children with computer skills Typemock™
  • 37. Not everything in life is easy… Typemock™
  • 38. Examples from the real world  Hard to unit test scenarios  How to solve this problem  Examples Typemock™
  • 39. Difficult scenarios to Unit Test  Client – server architecture  Databases  Legacy Code  Closed Object Models (Sharepoint, Silverlight)  GUI interaction Typemock™
  • 40. Possible solutions  First - better understand the problem  Design for Testability  Refactoring for Testability  Reflection  Mocks / Isolation  Last resort - Integration tests instead Typemock™
  • 41. Example Unit Testing WCF Client Class: WCF Client Method: string GetSourceList(string source); Problem: Server connection is not possible Typemock™
  • 42. Unit Testing WCF Client Overview: DataProviderClient DataProviderServer ISourceListProvider GetSourceList Typemock™
  • 43. Unit Testing Windows Forms Database Registration Form Business Logic Registration Controller Typemock™
  • 44. Share The Pain  Your unit testing stories  Q&A Typemock™
  • 45. Thank you Want to learn more? Read about Test Driven Development & Isolation at the Typemock Insiders blog Follow up on twitter.com/Typemock Take a card and drop us an email! Typemock™

Notes de l'éditeur

  1. The lecture today will be divided into four parts:1 Overview of Unit tests and TDD and how it could save money for companies and improve software development process2 Typical day (but nor all day) of a software developer that uses TDD3 Real examples of Unit testing in non trivial cases4 Answer questions from the audience about the lecture, TDD & Unit testing in their companies
  2. How a software company can benefit from unit testing Question to audience:Who knows what are unit tests?Who uses unit tests?Who practices TDD?
  3. Why unit test:Define unit testing, define isolationMotivationWhy not do unit testing?Benefits: regression, confidence in changeStatistics Examples of companies that unit testCommon misconceptions:Not all tests are unit tests (integration vs. unit testing)Unit tests are for developers, not QAIntroducing TDDTools:Unit testing frameworksR#Mocking frameworksTeamCity/Team SystemFinalBuilder/msbuild/ccnet
  4. Show unit test parts:Declaration (attribute)Run code under testAssertion – did satisfy condition Usually we have an additional part that arrange the needed componentsShould this be a new slide? What does unit test test?Functional requirememts
  5. First explain - Difference between unit testing – how and tdd - methodologyTest Driven Development (or test driven design) is a methodology.Write a test that failsRun tests – why should we – to make sure the test actually checks the right thingWrite codeRefactorRepeat if nessesary
  6. No that we understand what is unit testing and TDD I’d like
  7. Taken from http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdfRealizing quality improvement through test driven development: results and experiences of four industrial teamsPublished online: 27 February 2008
  8. - One known fact is that most of the bugs are introduced during the development stage.Another known fact is that the cost to fix a defect increases exponentially over stages.When bug is found at Testing phase the application needs to go back to development and it actually takes more time!It would be better to find/fix/not create bugs during development afterward it’s too late.We get a costly fix and frustrated clients.Show bugs in testing/supprt – where did they come from? Every few defects fixed a new defect is introducedOur pain in at the dev stage however many companies invest most of their money on QA & support
  9. Give example about massive refactoring of new code.Function/code afraid to touch…
  10. Examples DB, WCF
  11. Has Teardown/Setup functionalityRun Unit tests
  12. How to test part of a whole system
  13. The backbone of TDD (and development)Show how CI & script runner run the test suite – perhaps publish results to web
  14. Continuous integration is the backbone of TDD. Without test runner that runs each time code changes it is impossible to make sure that nothing was broken.
  15. Should show:? Get code from server ?MSTest/NUnit
  16. Should show:NUnit
  17. Resharper