SlideShare a Scribd company logo
1 of 29
Advanced Unit Testing – real life
examples and mistakes
Milan Vukoje
www.Vukoje.NET
vukoje@gmail.com
 Goals & Dangers
 Real life examples
 VS & TFS tips
 Best Practices
 Smells
Themes
 Improved quality
 SUT understanding
 Reduced risk
 Easy creation/maintaining
 Easy run
Goals of UT
 Additional costs
 Slowing down production code changing
 Losing tests in logic migration
 Tests take too long to write
 Poor Organization /Maintenance problems
Dangers of UT
Soprex Core Application (SCA)
DB
Win Web
UI
BL
DAL
SCRUM
Refactoring
Coding Standard
Code Review
 DB problems
 Persistent
 Slow
 Shared
 Complicated
Persistent fixture
DB
Win Web
UI
BL
DAL
 Shared Fixture + Partial cleanup
 Cleanup in Finally blocks
SCA.DAL – Cleanup Strategy
 Not treating tests as production code
 Do not duplicate test code
 Creation and Finder methods
 Custom Assertations
 Parameterized tests
 Test Run War
SCA.DAL
DB
Win Web
UI
BL
DAL
Database Sandbox
 Generic CRUD tests
 Uses generated values
 Tries to break constraints
 Insert nulls
 Max values
 Mini integration tests
 Great for detecting DB schema mismatch
SCA.BLTester
BL
DAL
DB
BLTester
SCA.BLTester example
SCA.BLTester cleanup
 Isolated Business Logic testing
 Mini Integration vs. FakeDB
 QueryObject + DataTable = FakeDB
 SCA.MockHelper
 Setup with Reflection
 Factory would be better choice
SCA.FakeDB
BL
DAL
DB
Fake DB
 Avoid Fragile Tests (To Pass or Not to Pass)
 Test Run War
 Non- deterministic tests
 Interacting tests
 Don’t use DB accident/random records
 When there is a way of testing w/o the DB,
test w/o DB.
 SCA.AppTranslation
 Testing w/o DB
 And than back to DB…
Lessons Learned
DB
Win Web
UI
BL
DAL
 Very important
 Bug can be very expensive
 Huge num. of combinations
 Integration Test failure
SCA.PriceCalculator
DB
Price Calculator
BL
DAL
Price
Request
Price
 Price Manager
 Simple calculations
 Easily tested with FakeDB
 Highly optimized cache
 Price Calculator
 Main algorithm
 Easily tested with Stub
 Concurrency control
Stub to the rescue!
DB
Price Calculator
BL
DAL
Price
Request
Price
Price Manager
When you have a new hammer, everything looks like a nail!
 Calculator example
 Use the Front Door First
 Guard Assert Example
Overdoing mocking
Use Case testing
DB
Win Web
UI
BL
DAL
 Model – View – Problem
 Presenter testing problems
 Not Isolated (GUI)
 Hard Indirect output control
 Testing Mocks
 Solution
 View Stub
 Setup Methods
SCA.UI
DB
Win Web
UI
BL
DAL
 Design for Testability
 Just a bit design upfront
 Be ware of the code smells
 Keep It Simple and Stupid (KISS)
 Always know what you are testing
Lessons learned
DB
Win Web
UI
BL
DAL
 Minimize untestable code
 Auto-synchronization
 Helper classes
 Indirect GUI control
 Don’t test GUI
 Also… buy GUI controls 
SCA.GUI
DB
Win Web
UI
BL
DAL
 Avoid Accessors
 Do not generate unit tests
 Avoid assertion roulette
 Use Assert class properly
Visual Studio tips
 Test Run & Build Policy
 Check-in Build & Build With Tests
 Nightly build with Code Analysis and Tests
 Build Error Notification
TFS - Continues Integration with
 Write the Tests First
 Communicate Intent
 Do not modify the SUT
 Keep Tests Independent
 Minimize Test Overlap
 Keep Test Logic Out of Production Code
 Verify One Condition per Test
More best practices…
 Design
 Long setup
 Hard to test code
 Slow tests
 Test logic in production
 Code
 Obscure test
 High test maintenance
 Conditional test logic
 Duplication
 Frequent Debugging
 Production bugs
Smells
 UT have grate benefits
 UT comes with dangers
 Watch the smells?
 Follow best practices
Summary
Questions?
Please fill the questionnaire !
You have a chance to win:
Sponsored by:
Thanks!
Milan Vukoje
www.Vukoje.NET
vukoje@gmail.com

More Related Content

What's hot

Test Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalTest Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalQA or the Highway
 
So you think you can write a test case
So you think you can write a test caseSo you think you can write a test case
So you think you can write a test caseSrilu Balla
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit TestingSahar Nofal
 
Unit testing
Unit testingUnit testing
Unit testingAdam Birr
 
An Overview of automated testing (1)
An Overview of automated testing (1)An Overview of automated testing (1)
An Overview of automated testing (1)Rodrigo Lopes
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)Foyzul Karim
 
Mock driven development using .NET
Mock driven development using .NETMock driven development using .NET
Mock driven development using .NETPuneet Ghanshani
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test casesConfiz
 
Moq presentation
Moq presentationMoq presentation
Moq presentationLynxStar
 
Roy Osherove TDD From Scratch
Roy Osherove TDD From ScratchRoy Osherove TDD From Scratch
Roy Osherove TDD From ScratchRoy Osherove
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testingSteven Casey
 
Good Unit Tests Ask For Quality Code
Good Unit Tests Ask For Quality CodeGood Unit Tests Ask For Quality Code
Good Unit Tests Ask For Quality CodeFlorin Coros
 
Test Cases Maintaining & Documenting
Test Cases Maintaining & DocumentingTest Cases Maintaining & Documenting
Test Cases Maintaining & DocumentingSeyed Ali Marjaie
 
Test case design_the_basicsv0.4
Test case design_the_basicsv0.4Test case design_the_basicsv0.4
Test case design_the_basicsv0.4guest31fced
 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard partsShaun Abram
 

What's hot (20)

Test Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalTest Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh Dahal
 
xUnit test patterns 0
xUnit test patterns 0xUnit test patterns 0
xUnit test patterns 0
 
So you think you can write a test case
So you think you can write a test caseSo you think you can write a test case
So you think you can write a test case
 
How to write defect
How to write defectHow to write defect
How to write defect
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
Clean code
Clean codeClean code
Clean code
 
Unit testing
Unit testingUnit testing
Unit testing
 
An Overview of automated testing (1)
An Overview of automated testing (1)An Overview of automated testing (1)
An Overview of automated testing (1)
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
 
Automated tests
Automated testsAutomated tests
Automated tests
 
Mock driven development using .NET
Mock driven development using .NETMock driven development using .NET
Mock driven development using .NET
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
 
Moq presentation
Moq presentationMoq presentation
Moq presentation
 
Roy Osherove TDD From Scratch
Roy Osherove TDD From ScratchRoy Osherove TDD From Scratch
Roy Osherove TDD From Scratch
 
Php tests tips
Php tests tipsPhp tests tips
Php tests tips
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testing
 
Good Unit Tests Ask For Quality Code
Good Unit Tests Ask For Quality CodeGood Unit Tests Ask For Quality Code
Good Unit Tests Ask For Quality Code
 
Test Cases Maintaining & Documenting
Test Cases Maintaining & DocumentingTest Cases Maintaining & Documenting
Test Cases Maintaining & Documenting
 
Test case design_the_basicsv0.4
Test case design_the_basicsv0.4Test case design_the_basicsv0.4
Test case design_the_basicsv0.4
 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard parts
 

Viewers also liked

Dan Solovay - Test Driven Sitecore - SUGCON
Dan Solovay - Test Driven Sitecore - SUGCONDan Solovay - Test Driven Sitecore - SUGCON
Dan Solovay - Test Driven Sitecore - SUGCONSUGCON
 
User Testing by Example
User Testing by ExampleUser Testing by Example
User Testing by ExampleJeremy Horn
 
Agile testing and_the_banking_domain_2009
Agile testing and_the_banking_domain_2009Agile testing and_the_banking_domain_2009
Agile testing and_the_banking_domain_2009Anil Kumar
 
Is an agile SDLC an oxymoron?
Is an agile SDLC an oxymoron? Is an agile SDLC an oxymoron?
Is an agile SDLC an oxymoron? Dave Sharrock
 
Testing of e-Banking - Case Study
Testing of e-Banking - Case Study Testing of e-Banking - Case Study
Testing of e-Banking - Case Study OAK Systems Pvt Ltd
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Enea Gabriel
 
Linking Upstream and Downstream Agile
Linking Upstream and Downstream AgileLinking Upstream and Downstream Agile
Linking Upstream and Downstream AgileCollabNet
 
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!MAXXYS AG
 
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 JSMichael Haberman
 
The Impact of Big Data On Marketing Analytics (UpStream Software)
The Impact of Big Data On Marketing Analytics (UpStream Software)The Impact of Big Data On Marketing Analytics (UpStream Software)
The Impact of Big Data On Marketing Analytics (UpStream Software)Revolution Analytics
 
JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6Bert Ertman
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and typesConfiz
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software TestingNishant Worah
 
Integration Test Hell
Integration Test HellIntegration Test Hell
Integration Test HellDavid Völkel
 
Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...
Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...
Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...SwissQ Consulting AG
 

Viewers also liked (18)

Dan Solovay - Test Driven Sitecore - SUGCON
Dan Solovay - Test Driven Sitecore - SUGCONDan Solovay - Test Driven Sitecore - SUGCON
Dan Solovay - Test Driven Sitecore - SUGCON
 
User Testing by Example
User Testing by ExampleUser Testing by Example
User Testing by Example
 
QA Tester Junior
QA Tester JuniorQA Tester Junior
QA Tester Junior
 
Agile testing and_the_banking_domain_2009
Agile testing and_the_banking_domain_2009Agile testing and_the_banking_domain_2009
Agile testing and_the_banking_domain_2009
 
Is an agile SDLC an oxymoron?
Is an agile SDLC an oxymoron? Is an agile SDLC an oxymoron?
Is an agile SDLC an oxymoron?
 
Browser-level testing
Browser-level testingBrowser-level testing
Browser-level testing
 
Testing of e-Banking - Case Study
Testing of e-Banking - Case Study Testing of e-Banking - Case Study
Testing of e-Banking - Case Study
 
Agile Testing - Challenges
Agile Testing - ChallengesAgile Testing - Challenges
Agile Testing - Challenges
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
 
Linking Upstream and Downstream Agile
Linking Upstream and Downstream AgileLinking Upstream and Downstream Agile
Linking Upstream and Downstream Agile
 
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
End-2-End Monitoring – Der Prüfstand jedes SLA´s – in 15 Minuten erklärt!
 
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
 
The Impact of Big Data On Marketing Analytics (UpStream Software)
The Impact of Big Data On Marketing Analytics (UpStream Software)The Impact of Big Data On Marketing Analytics (UpStream Software)
The Impact of Big Data On Marketing Analytics (UpStream Software)
 
JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software Testing
 
Integration Test Hell
Integration Test HellIntegration Test Hell
Integration Test Hell
 
Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...
Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...
Software Development 2014: Trends & Benchmarks in Agile, Requirements and Tes...
 

Similar to Advanced unit testing – real life examples and mistakes

No More No Repro
No More No ReproNo More No Repro
No More No ReproAnna Russo
 
Microsoft Stack Visual Studio 2010 Overview
Microsoft  Stack   Visual Studio 2010 OverviewMicrosoft  Stack   Visual Studio 2010 Overview
Microsoft Stack Visual Studio 2010 Overviewrfennell
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioNCCOMMS
 
Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010Ed Blankenship
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009Pepe
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated TestingLee Englestone
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Steve Lange
 
Application Lifecycle Management with TFS
Application Lifecycle Management with TFSApplication Lifecycle Management with TFS
Application Lifecycle Management with TFSMehdi Khalili
 
Software Development Practices in Practice
Software Development Practices in PracticeSoftware Development Practices in Practice
Software Development Practices in PracticeDennis Doomen
 
Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NETPeter Gfader
 
Software Reengineering
Software ReengineeringSoftware Reengineering
Software ReengineeringBradley Irby
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual TestingDirecti Group
 
Automated+Testing+Vs+Manual+Testing
Automated+Testing+Vs+Manual+TestingAutomated+Testing+Vs+Manual+Testing
Automated+Testing+Vs+Manual+Testinggueste1e4db
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testingdidev
 
BJDsolutions.com agile process
BJDsolutions.com agile processBJDsolutions.com agile process
BJDsolutions.com agile processbjdsolutions
 
Full Testing Experience - Visual Studio and TFS 2010
 Full Testing Experience - Visual Studio and TFS 2010 Full Testing Experience - Visual Studio and TFS 2010
Full Testing Experience - Visual Studio and TFS 2010Ed Blankenship
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databasesAlessandro Alpi
 
Rhapsody Systems Software
Rhapsody Systems SoftwareRhapsody Systems Software
Rhapsody Systems SoftwareBill Duncan
 

Similar to Advanced unit testing – real life examples and mistakes (20)

No More No Repro
No More No ReproNo More No Repro
No More No Repro
 
Microsoft Stack Visual Studio 2010 Overview
Microsoft  Stack   Visual Studio 2010 OverviewMicrosoft  Stack   Visual Studio 2010 Overview
Microsoft Stack Visual Studio 2010 Overview
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
 
Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
Application Lifecycle Management with TFS
Application Lifecycle Management with TFSApplication Lifecycle Management with TFS
Application Lifecycle Management with TFS
 
Software Development Practices in Practice
Software Development Practices in PracticeSoftware Development Practices in Practice
Software Development Practices in Practice
 
Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NET
 
Software Reengineering
Software ReengineeringSoftware Reengineering
Software Reengineering
 
Vsts 2
Vsts 2Vsts 2
Vsts 2
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testing
 
Automated+Testing+Vs+Manual+Testing
Automated+Testing+Vs+Manual+TestingAutomated+Testing+Vs+Manual+Testing
Automated+Testing+Vs+Manual+Testing
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testing
 
BJDsolutions.com agile process
BJDsolutions.com agile processBJDsolutions.com agile process
BJDsolutions.com agile process
 
Full Testing Experience - Visual Studio and TFS 2010
 Full Testing Experience - Visual Studio and TFS 2010 Full Testing Experience - Visual Studio and TFS 2010
Full Testing Experience - Visual Studio and TFS 2010
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
 
Test driving an MVVM App
Test driving an MVVM AppTest driving an MVVM App
Test driving an MVVM App
 
Rhapsody Systems Software
Rhapsody Systems SoftwareRhapsody Systems Software
Rhapsody Systems Software
 

More from Milan Vukoje

State of the art logging
State of the art loggingState of the art logging
State of the art loggingMilan Vukoje
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code ReviewMilan Vukoje
 
Soprex framework on .net in action
Soprex framework on .net in actionSoprex framework on .net in action
Soprex framework on .net in actionMilan Vukoje
 
Unit testing solid fundamentals
Unit testing solid fundamentalsUnit testing solid fundamentals
Unit testing solid fundamentalsMilan Vukoje
 

More from Milan Vukoje (6)

Juniori/Seniori
Juniori/SenioriJuniori/Seniori
Juniori/Seniori
 
State of the art logging
State of the art loggingState of the art logging
State of the art logging
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 
Soprex framework on .net in action
Soprex framework on .net in actionSoprex framework on .net in action
Soprex framework on .net in action
 
Unit testing solid fundamentals
Unit testing solid fundamentalsUnit testing solid fundamentals
Unit testing solid fundamentals
 

Recently uploaded

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 Processorsdebabhi2
 
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
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
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)

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
 
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...
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Advanced unit testing – real life examples and mistakes

  • 1. Advanced Unit Testing – real life examples and mistakes Milan Vukoje www.Vukoje.NET vukoje@gmail.com
  • 2.  Goals & Dangers  Real life examples  VS & TFS tips  Best Practices  Smells Themes
  • 3.  Improved quality  SUT understanding  Reduced risk  Easy creation/maintaining  Easy run Goals of UT
  • 4.  Additional costs  Slowing down production code changing  Losing tests in logic migration  Tests take too long to write  Poor Organization /Maintenance problems Dangers of UT
  • 5. Soprex Core Application (SCA) DB Win Web UI BL DAL SCRUM Refactoring Coding Standard Code Review
  • 6.  DB problems  Persistent  Slow  Shared  Complicated Persistent fixture DB Win Web UI BL DAL
  • 7.  Shared Fixture + Partial cleanup  Cleanup in Finally blocks SCA.DAL – Cleanup Strategy
  • 8.  Not treating tests as production code  Do not duplicate test code  Creation and Finder methods  Custom Assertations  Parameterized tests  Test Run War SCA.DAL DB Win Web UI BL DAL
  • 10.  Generic CRUD tests  Uses generated values  Tries to break constraints  Insert nulls  Max values  Mini integration tests  Great for detecting DB schema mismatch SCA.BLTester BL DAL DB BLTester
  • 13.  Isolated Business Logic testing  Mini Integration vs. FakeDB  QueryObject + DataTable = FakeDB  SCA.MockHelper  Setup with Reflection  Factory would be better choice SCA.FakeDB BL DAL DB Fake DB
  • 14.  Avoid Fragile Tests (To Pass or Not to Pass)  Test Run War  Non- deterministic tests  Interacting tests  Don’t use DB accident/random records  When there is a way of testing w/o the DB, test w/o DB.  SCA.AppTranslation  Testing w/o DB  And than back to DB… Lessons Learned DB Win Web UI BL DAL
  • 15.  Very important  Bug can be very expensive  Huge num. of combinations  Integration Test failure SCA.PriceCalculator DB Price Calculator BL DAL Price Request Price
  • 16.  Price Manager  Simple calculations  Easily tested with FakeDB  Highly optimized cache  Price Calculator  Main algorithm  Easily tested with Stub  Concurrency control Stub to the rescue! DB Price Calculator BL DAL Price Request Price Price Manager
  • 17. When you have a new hammer, everything looks like a nail!  Calculator example  Use the Front Door First  Guard Assert Example Overdoing mocking
  • 18. Use Case testing DB Win Web UI BL DAL
  • 19.  Model – View – Problem  Presenter testing problems  Not Isolated (GUI)  Hard Indirect output control  Testing Mocks  Solution  View Stub  Setup Methods SCA.UI DB Win Web UI BL DAL
  • 20.  Design for Testability  Just a bit design upfront  Be ware of the code smells  Keep It Simple and Stupid (KISS)  Always know what you are testing Lessons learned DB Win Web UI BL DAL
  • 21.  Minimize untestable code  Auto-synchronization  Helper classes  Indirect GUI control  Don’t test GUI  Also… buy GUI controls  SCA.GUI DB Win Web UI BL DAL
  • 22.  Avoid Accessors  Do not generate unit tests  Avoid assertion roulette  Use Assert class properly Visual Studio tips
  • 23.  Test Run & Build Policy  Check-in Build & Build With Tests  Nightly build with Code Analysis and Tests  Build Error Notification TFS - Continues Integration with
  • 24.  Write the Tests First  Communicate Intent  Do not modify the SUT  Keep Tests Independent  Minimize Test Overlap  Keep Test Logic Out of Production Code  Verify One Condition per Test More best practices…
  • 25.  Design  Long setup  Hard to test code  Slow tests  Test logic in production  Code  Obscure test  High test maintenance  Conditional test logic  Duplication  Frequent Debugging  Production bugs Smells
  • 26.  UT have grate benefits  UT comes with dangers  Watch the smells?  Follow best practices Summary
  • 28. Please fill the questionnaire ! You have a chance to win: Sponsored by: