SlideShare a Scribd company logo
1 of 28
Unit Testing
Abhinav Gujjar

@abhinavgujjar
RULES!

Mobiles on Silent mode
Ask
Ask
Ask again
Agenda
What is Unit Testing
Why unit test ?
Unit Testing Frameworks for .Net
Best Practices for unit testing
Test Driven Development (TDD)
Unit testing in Agile
Urgh – Not my job
I’m a Developer.
I don’t test.

I pay testers for
testing
In The Real World
In The Real World
Different Types of Testing
Unit Testing

Development

Functional
Testing

Testing

Acceptance
Testing

Deployment

Integration
Testing
DEMO

Simple Interest Calculation
What?

You are already doing it
… But not correctly

Prove the correctness of a small isolated piece of
functionality in a larger system
Why?

Higher Quality
Better Code
Documentation
How?

Unit Testing Frameworks

.Net
nUnit
xUnit
msTest
Demo

Creating unit tests
Anatomy
Arrange
Unit Test
Framework
Unit Tests

Act

Assert
Red-Green Refactor Cycle

Red

Refactor

Green
One Assert per test

One logical assertion per test
May need more than one Assert statement
Qualities of a Unit Test

Repeatable
Independent
Exercise

Writing Tests
Testing the Sad Path
Assertions !

Simple Assertions
Collection Asserts
String Asserts
Test Setup and Tear Downs

Assembly
Class
Test
Isolating Code
Isolation Techniques
Dummies
Stubs
Fake – Maintain State
Spy – Maintains state and is available for assertion

Mock – Complex behavior
Mocking Frameworks

Moq
RhinoMocks
nMock
Silverlight Unit Testing

Tests are run on the browser
Moq available! Yay !
But - Only if you use the MVVM pattern
View Model First Approach
Refactoring
When is done done ?
Code may be correct
But is it healthy?

 Readability
 Maintainability
 What about performance ?
 Technical Debt
Code Smells
 Duplicated Code
 Long Method
 Long Parameter List

 Large Class
 Comments !!
 Switch statements

 Dead Code
…
…
Testing Legacy Code

Why?
When?
How?
Happy Unit Testing!

Blog: www.rubiksquare.com
Discussion: http://www.rubiksquare.com/p/discuss.html
LinkedIn : http://www.linkedin.com/in/abhinavgujjar
mail: Abhinavgujjar@gmail.com

More Related Content

What's hot

Writing Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designsWriting Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designslachlandonald
 
Unit testing
Unit testing Unit testing
Unit testing dubbu
 
Unit Testing Guidelines
Unit Testing GuidelinesUnit Testing Guidelines
Unit Testing GuidelinesJoel Hooks
 
Open source bridge testing antipatterns presentation
Open source bridge testing antipatterns presentationOpen source bridge testing antipatterns presentation
Open source bridge testing antipatterns presentationmmrobins
 
Exploratory Testing in an Agile Context
Exploratory Testing in an Agile ContextExploratory Testing in an Agile Context
Exploratory Testing in an Agile ContextElisabeth Hendrickson
 
Clean and Quality Unit Tests
Clean and Quality Unit TestsClean and Quality Unit Tests
Clean and Quality Unit TestsWojtek Zieliński
 
SCJP Preparation Tips
SCJP Preparation TipsSCJP Preparation Tips
SCJP Preparation TipsGanesh P
 
Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqXPDays
 
An insight to test driven development and unit testing
An insight to test driven development and unit testingAn insight to test driven development and unit testing
An insight to test driven development and unit testingDharmendra Prasad
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguy_davis
 
Pertanyaan dan jawaban (graham et.al 2011) part 3
Pertanyaan dan jawaban (graham et.al 2011) part 3Pertanyaan dan jawaban (graham et.al 2011) part 3
Pertanyaan dan jawaban (graham et.al 2011) part 3ikhwana luthfi
 
What is What is Professional Testing?
What is What is Professional Testing?What is What is Professional Testing?
What is What is Professional Testing?James Thomas
 
Do we really need game testers?
Do we really need game testers?Do we really need game testers?
Do we really need game testers?Johan Hoberg
 
Unit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonUnit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonSeb Rose
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven DevelopmentFerdous Mahmud Shaon
 

What's hot (20)

Writing Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designsWriting Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designs
 
Unit testing
Unit testing Unit testing
Unit testing
 
Unit Testing Guidelines
Unit Testing GuidelinesUnit Testing Guidelines
Unit Testing Guidelines
 
Open source bridge testing antipatterns presentation
Open source bridge testing antipatterns presentationOpen source bridge testing antipatterns presentation
Open source bridge testing antipatterns presentation
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Exploratory Testing in an Agile Context
Exploratory Testing in an Agile ContextExploratory Testing in an Agile Context
Exploratory Testing in an Agile Context
 
Clean and Quality Unit Tests
Clean and Quality Unit TestsClean and Quality Unit Tests
Clean and Quality Unit Tests
 
Unit testing - An introduction
Unit testing - An introductionUnit testing - An introduction
Unit testing - An introduction
 
Exploratory Testing in Practice
Exploratory Testing in PracticeExploratory Testing in Practice
Exploratory Testing in Practice
 
SCJP Preparation Tips
SCJP Preparation TipsSCJP Preparation Tips
SCJP Preparation Tips
 
Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and Moq
 
An insight to test driven development and unit testing
An insight to test driven development and unit testingAn insight to test driven development and unit testing
An insight to test driven development and unit testing
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Pertanyaan dan jawaban (graham et.al 2011) part 3
Pertanyaan dan jawaban (graham et.al 2011) part 3Pertanyaan dan jawaban (graham et.al 2011) part 3
Pertanyaan dan jawaban (graham et.al 2011) part 3
 
What is What is Professional Testing?
What is What is Professional Testing?What is What is Professional Testing?
What is What is Professional Testing?
 
Do we really need game testers?
Do we really need game testers?Do we really need game testers?
Do we really need game testers?
 
Assertj
AssertjAssertj
Assertj
 
Unit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonUnit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking Skeleton
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 

Viewers also liked

презентация сёть1
презентация сёть1презентация сёть1
презентация сёть1Kseniya Skryabina
 
AHCapabilities - Quebec, Canada (Liquids)
AHCapabilities - Quebec, Canada (Liquids)AHCapabilities - Quebec, Canada (Liquids)
AHCapabilities - Quebec, Canada (Liquids)Alcrea
 
Working smarter
Working smarterWorking smarter
Working smartersmithjmk3
 
Alcrea+SourceOne Present VESIsorb ExpoWest2013
Alcrea+SourceOne Present VESIsorb ExpoWest2013Alcrea+SourceOne Present VESIsorb ExpoWest2013
Alcrea+SourceOne Present VESIsorb ExpoWest2013Alcrea
 
[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...
[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...
[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...FrenchWeb.fr
 
Rapport d'orientation 2016
Rapport d'orientation 2016Rapport d'orientation 2016
Rapport d'orientation 2016alpha-asso49
 

Viewers also liked (11)

Wzory
WzoryWzory
Wzory
 
презентация сёть1
презентация сёть1презентация сёть1
презентация сёть1
 
Uday_P_Singh
Uday_P_SinghUday_P_Singh
Uday_P_Singh
 
AHCapabilities - Quebec, Canada (Liquids)
AHCapabilities - Quebec, Canada (Liquids)AHCapabilities - Quebec, Canada (Liquids)
AHCapabilities - Quebec, Canada (Liquids)
 
Working smarter
Working smarterWorking smarter
Working smarter
 
Alcrea+SourceOne Present VESIsorb ExpoWest2013
Alcrea+SourceOne Present VESIsorb ExpoWest2013Alcrea+SourceOne Present VESIsorb ExpoWest2013
Alcrea+SourceOne Present VESIsorb ExpoWest2013
 
Tarotmag n°19
Tarotmag n°19Tarotmag n°19
Tarotmag n°19
 
[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...
[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...
[FW Invest Janvier 2017] Près de 200 millions d’euros levés par des entrepris...
 
Rapport d'orientation 2016
Rapport d'orientation 2016Rapport d'orientation 2016
Rapport d'orientation 2016
 
rapportDigital-TV
rapportDigital-TVrapportDigital-TV
rapportDigital-TV
 
ref105
ref105ref105
ref105
 

Similar to Unit testing

Automated Unit Testing for Mere Mortals
Automated Unit Testing for Mere MortalsAutomated Unit Testing for Mere Mortals
Automated Unit Testing for Mere MortalsJess Chadwick
 
Real Life Unit Testing
Real Life Unit TestingReal Life Unit Testing
Real Life Unit TestingDror Helper
 
Agile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All WorksAgile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All WorksElisabeth Hendrickson
 
Project Management in 3 Slides
Project Management in 3 SlidesProject Management in 3 Slides
Project Management in 3 SlidesLonnie Sorrells
 
STOP! You're Testing Too Much - Shawn Wallace
STOP!  You're Testing Too Much - Shawn WallaceSTOP!  You're Testing Too Much - Shawn Wallace
STOP! You're Testing Too Much - Shawn WallaceQA or the Highway
 
Stop! you're testing too much
Stop!  you're testing too muchStop!  you're testing too much
Stop! you're testing too muchShawn Wallace
 
Introduction of unit test to management
Introduction of unit test to managementIntroduction of unit test to management
Introduction of unit test to managementweili_at_slideshare
 
Tdd Ugialtnet Jan2010
Tdd Ugialtnet Jan2010Tdd Ugialtnet Jan2010
Tdd Ugialtnet Jan2010guestcff805
 
Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testingPavlo Hodysh
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit TestingSahar Nofal
 

Similar to Unit testing (20)

Automated Unit Testing for Mere Mortals
Automated Unit Testing for Mere MortalsAutomated Unit Testing for Mere Mortals
Automated Unit Testing for Mere Mortals
 
Unit testing, principles
Unit testing, principlesUnit testing, principles
Unit testing, principles
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Real Life Unit Testing
Real Life Unit TestingReal Life Unit Testing
Real Life Unit Testing
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Unit testing
Unit testingUnit testing
Unit testing
 
Insoft training day_1
Insoft training day_1Insoft training day_1
Insoft training day_1
 
Agile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All WorksAgile Testing, Uncertainty, Risk, and Why It All Works
Agile Testing, Uncertainty, Risk, and Why It All Works
 
Agile Testing Overview
Agile Testing OverviewAgile Testing Overview
Agile Testing Overview
 
Project Management in 3 Slides
Project Management in 3 SlidesProject Management in 3 Slides
Project Management in 3 Slides
 
STOP! You're Testing Too Much - Shawn Wallace
STOP!  You're Testing Too Much - Shawn WallaceSTOP!  You're Testing Too Much - Shawn Wallace
STOP! You're Testing Too Much - Shawn Wallace
 
Stop! you're testing too much
Stop!  you're testing too muchStop!  you're testing too much
Stop! you're testing too much
 
Introduction of unit test to management
Introduction of unit test to managementIntroduction of unit test to management
Introduction of unit test to management
 
Testing in java
Testing in javaTesting in java
Testing in java
 
Tdd Ugialtnet Jan2010
Tdd Ugialtnet Jan2010Tdd Ugialtnet Jan2010
Tdd Ugialtnet Jan2010
 
Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testing
 
Agile test practices
Agile test practicesAgile test practices
Agile test practices
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 

Recently uploaded

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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...Martijn de Jong
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Unit testing

Editor's Notes

  1. IntroductionsAbhinav Gujjar from
  2. Only bad questions are the ones that were not asked
  3. Unit Testing frameworksnUnitxUnitmsTestBest PractisesIsolation Refactoring
  4. The job is to deliver a software product, not focus on roles.Especially in Agile developmentCosts 500% more to fix bugs in production than it does before leaving the developers code“Inspection at the point of creation”
  5. Functional testing is done by the QA teamThey are trying to cover user related functionalities (Similar to switching on the light)They may be looking at negative test scenarios. But they can never replicate all the circumstancesAcceptance testing is usually done by the clients.Most of the time is spent in developmentThe quicker the bugs are caught, the cheaper it is to fix themSometimes the testing phase is already too late for bugsFunctional testing
  6. How will you send the input ? Change the visual studio startup optionsGo to command line and pass in the parametersHow will you check the output ?Debug modeOR console.writelineWhat about multiple tests ?All the test scenario information is lost and thus not repeatable
  7. Unit testing frameworks are available for almost every popular language.nUnit – ported from javas junit. GrandfatherxUnit – Newcomer. Different implementation. Open SourcemsTest – integrated into visual studioMost of these will have a command line runner.Demonstrate with diagram how this might work
  8. Should be a separate project – to ensure that test are not deployed Also – more importantly to ensure that we are testing only the public interfaces of the targetTest Runner – will pass or failCan debug into the testsOne test per project, or a single test project for Always require the reference to a domain project + reference to the unit testing framework
  9. Separate test project because you may not want to ship the testing code along with
  10. Keep things simpleOnly add functionality that is required to make the test passCreating a failing testMake the test passRefactor – Improve the internal implementationRefactoring is made a lot more reliable. You will find a way to write code in a manner that makes it testable
  11. Repeatable – for instance based on a time factorRun them in any order
  12. Catching exceptions
  13. Dummies are objects that the SUT won’t be using them in a meaningful wayStubs are empty classes or objectsFakes may contain a little more complex implementationSpies