unit testing

12
Unit Testing Secrets of an Umbraco Ninja Presented by : Aaron Powell [email protected] @slace www.aaron-powell.com

Upload: wilmet

Post on 22-Feb-2016

21 views

Category:

Documents


0 download

DESCRIPTION

Unit Testing. Secrets of an Umbraco Ninja. Presented by : Aaron Powell. [email protected]. @ slace. www.aaron-powell.com. What and Why?. Not Test Driven Development Separation of logic from UI Ability to create reusable components - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Unit Testing

Unit TestingSecrets of an Umbraco Ninja

Presented by:

Aaron [email protected]

@slace www.aaron-powell.com

Page 2: Unit Testing

• Not Test Driven Development• Separation of logic from UI• Ability to create reusable components• Reduced errors by repeatable tests in

controlled environments• Better API design

What and Why?

Page 3: Unit Testing

Umbraco UI

Page 4: Unit Testing

Code

Build

Deploy

Test

Page 5: Unit Testing

Umbraco

Logic

UITests

Page 6: Unit Testing

Code

Test

BuildDeploy

Test

Page 7: Unit Testing

• Stub is an instance which wont break your test– Stubs can be implementations of a class

created purely for testing purposes• Mocks– Less common in current unit testing– Type instances where nothing is defined– Can be very brittle

Stub & Mocks

Page 8: Unit Testing

• Do you need a mocking framework?– Short answer is no– Can create your own stub types– Gives you greater control

• Why to use one?– Easy expectation setup– Using stubs on less accessible types

• Set-less properties

Frameworks

Page 9: Unit Testing

• WebForms MVP to abstract away ASP.NET WebForms features

• Dependency Injection to simplify the creation of factory types

• Factory Pattern for data access

Development

Page 10: Unit Testing

• Heavy reliance of HttpContext– Hard to Mock– Requires a web context

• Lots of static– Hard to mock

• Changing data– What are we working against?

With Umbraco

Page 11: Unit Testing

Ninja Coding!

Page 12: Unit Testing

Questions?Thank you for coming