phx - session #2 test driven development: improving .net application performance & scalability
DESCRIPTION
TRANSCRIPT
![Page 1: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/1.jpg)
TEAM SYSTEM: IT’S BIG
Test Driven DevelopmentImproving .NET Application Performance & Scalability
Brendon Birdoes([email protected]
om)
![Page 2: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/2.jpg)
TEAM SYSTEM: IT’S BIG
Agenda• Challenges we deal with today• Be Agile - Test Driven Development• Code coverage• Database can be Unit Tested!• Benefits of TDD• Summary• Q&A
![Page 3: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/3.jpg)
TEAM SYSTEM: IT’S BIG
Challenges we deal with today
• Does our code do what we intended?• Documentation – is it updated?• Debug – again?• Change Request – What did I break?
![Page 4: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/4.jpg)
TEAM SYSTEM: IT’S BIG
Get Agile – Test Driven Development
Tools For Agility, Kent Beck
Practices
Tools
![Page 5: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/5.jpg)
TEAM SYSTEM: IT’S BIG
Unit Test Defined• Code programmers write to exercise
each method in the design that run quickly and help localize errors – Isolates and tests a single operation– Run in any environment– Less time debugging– Side affect is documentation!
![Page 6: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/6.jpg)
TEAM SYSTEM: IT’S BIG
Unit Tests Defined• Tests are NOT unit tests when
they…– Talk to a database– Communicate across the network– Touch the file system– Require human intervention (such as
modifying a *.config file, starting a console app, etc.) to run
![Page 7: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/7.jpg)
TEAM SYSTEM: IT’S BIG
What is Test Driven Development?
• Despite the name, TDD focuses on “Design” first, “Test” second
• Basic tenants are:–Write a failing automated test before
you write any code• Focus on interface and use case or problem• Tests get written• Just enough code to pass the test
– Remove duplication (refactor)
![Page 8: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/8.jpg)
TEAM SYSTEM: IT’S BIG
Test Driven DevelopmentThe motto "Red, Green,
Refactor ".
![Page 9: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/9.jpg)
TEAM SYSTEM: IT’S BIG
demoDeveloper Unit Test
![Page 10: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/10.jpg)
TEAM SYSTEM: IT’S BIG
Code Coverage Defined• Also known as “test coverage”• It measures how thoroughly the
automated tests exercise the production code, its source code statements, branches, and expressions
![Page 11: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/11.jpg)
TEAM SYSTEM: IT’S BIG
What degree of code coverage should you aim for?
• Answer: It depends• Average code coverage is around
85%• Biggest blocker to attain 100% -
existing code, auto generated code• Aim for 100% while learning – you’ll
understand why 85% is nicer
![Page 12: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/12.jpg)
TEAM SYSTEM: IT’S BIG
demoCode Coverage
![Page 13: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/13.jpg)
TEAM SYSTEM: IT’S BIG
Database can be Unit Tested!
User Interface
ApplicationCode
UnitTestsData Access
Layer
Stored Procedures
![Page 14: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/14.jpg)
TEAM SYSTEM: IT’S BIG
demoDatabase Unit Test
![Page 15: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/15.jpg)
TEAM SYSTEM: IT’S BIG
TDD in Action: Active BugBug: Expired Credit Cards are being
Credited
![Page 16: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/16.jpg)
TEAM SYSTEM: IT’S BIG
Quality Indicators
Iteration 1 Iteration 3 Iteration 4 Iteration 5Iteration 2
91
20
51
76
60
56
19
18
40
71
80
32.5
12
8
9
![Page 17: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/17.jpg)
TEAM SYSTEM: IT’S BIG
Traditional testing
![Page 18: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/18.jpg)
TEAM SYSTEM: IT’S BIG
Test Driven Development
![Page 19: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/19.jpg)
TEAM SYSTEM: IT’S BIG
TDD - Application Lifecycle
Development Testing & Bug Fixing UATDevelopment
Testing & Bug
FixingUAT
Development and testing/bug fixing take about the same amount of time Development takes more time than testing, and testing time is reduced
Overall lifecycle is shortened
![Page 20: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/20.jpg)
TEAM SYSTEM: IT’S BIG
Unit testing is a learned skill that can only be honed with
experience.
Interfaces
Mock Objects
Better Factored Code
![Page 21: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/21.jpg)
TEAM SYSTEM: IT’S BIG
Starting Test Driven Development
Creating a cultural change is hard…
….. and it can be done.
![Page 22: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/22.jpg)
TEAM SYSTEM: IT’S BIG
Summary• Development becomes more
challenging.• TDD is a great tool to overcome these
challenges• Database can be Unit Tested!• Development is Faster using TDD.• VSTS is a great tool for UT and TDD.
![Page 23: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/23.jpg)
TEAM SYSTEM: IT’S BIG
Q & A
![Page 24: PHX - Session #2 Test Driven Development: Improving .NET Application Performance & Scalability](https://reader034.vdocuments.site/reader034/viewer/2022051817/54834144b07959240c8b49dc/html5/thumbnails/24.jpg)
TEAM SYSTEM: IT’S BIG