View
335
Download
0
Category
Preview:
Citation preview
Unit Testing and Tools
Wm. Barrett Simmsbarrett@wbsimms.com
@wbsimms
Sponsor Thanks!
About MeSoftware
Developer
Agile Team Member
Team LeadAgile Advocate
SDLC Implemente
r
What are your variable costs?
Requirements Quality Defects / Testing
Technical Skill Infrastructure
These are under your control
The measurement process
Take Action
Identify Problem
sMeasure
SDLC
Vocabulary• Unit test
• Code you write to test your code
• Coverage• Measure of how much code is tested
• Mock• Replacement for something else
• Dependency Injection (DI)• Builder design pattern• Object and dependencies are created for you
• Continuous Integration (CI)• Responds to check-ins, builds code, and generates code metrics (coverage, unit test pass fail, etc.)
Why Unit Test?• Which would you rather do?
Write CodeManual Testing
&Fix Bugs
That’s cute… but really…• Catches regression bugs at the developers desk• Documents how code works• Catalog of the business rules
What makes a good unit test?• Repeatable• Fast• Test by layers• Good Coverage
Test by layersComponent
Sub-component 1 Sub-component 2
Sub-component 3Sub-component 4
Sub-component 1 Mock Sub-component 2
Mock Sub-component 4
When do you run your test?
•All tests all the time! After pull / sync Before commits During CI builds Before you merge After you merge
Excuses• It takes too long to write• It takes too long to run• It’s not my job• I don’t understand how the code is supposed to behave so I can’t
test it
It takes too long
My toolset• MSTest• Unit testing framework
• Moq• Creating mock objects from interfaces
• Unity• Dependency Injection
• MSBuild• Build automation
• Ncover• For coverage analysis
Base Project• Project Roller
• https://github.com/wbsimms/ProjectRoller• ASP.NET MVC 5.x• EF 6.x• Unity Dependency Injection 4.x• Angular 1.5• Bootstrap• Moq• Complete build system
• MSBuild• Ncover• Simian• Database creation and seeding
• More…
Demo
Deep breath…
Recommended