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

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

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: