18
Unit Testing and Tools Wm. Barrett Simms [email protected] @wbsimms

Unit Testing and Tools - ADNUG

Embed Size (px)

Citation preview

Page 1: Unit Testing and Tools - ADNUG

Unit Testing and Tools

Wm. Barrett [email protected]

@wbsimms

Page 2: Unit Testing and Tools - ADNUG

Sponsor Thanks!

Page 3: Unit Testing and Tools - ADNUG
Page 4: Unit Testing and Tools - ADNUG

About MeSoftware

Developer

Agile Team Member

Team LeadAgile Advocate

SDLC Implemente

r

Page 5: Unit Testing and Tools - ADNUG

What are your variable costs?

Requirements Quality Defects / Testing

Technical Skill Infrastructure

These are under your control

Page 6: Unit Testing and Tools - ADNUG

The measurement process

Take Action

Identify Problem

sMeasure

Page 7: Unit Testing and Tools - ADNUG

SDLC

Page 8: Unit Testing and Tools - ADNUG

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.)

Page 9: Unit Testing and Tools - ADNUG

Why Unit Test?• Which would you rather do?

Write CodeManual Testing

&Fix Bugs

Page 10: Unit Testing and Tools - ADNUG

That’s cute… but really…• Catches regression bugs at the developers desk• Documents how code works• Catalog of the business rules

Page 11: Unit Testing and Tools - ADNUG

What makes a good unit test?• Repeatable• Fast• Test by layers• Good Coverage

Page 12: Unit Testing and Tools - ADNUG

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

Page 13: Unit Testing and Tools - ADNUG

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

Page 14: Unit Testing and Tools - ADNUG

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

Page 15: Unit Testing and Tools - ADNUG

It takes too long

Page 16: Unit Testing and Tools - ADNUG

My toolset• MSTest• Unit testing framework

• Moq• Creating mock objects from interfaces

• Unity• Dependency Injection

• MSBuild• Build automation

• Ncover• For coverage analysis

Page 17: Unit Testing and Tools - ADNUG

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…

Page 18: Unit Testing and Tools - ADNUG

Demo

Deep breath…