Unit Testing 101

18 %
82 %
Information about Unit Testing 101

Published on March 25, 2009

Author: dbouwman

Source: slideshare.net


Unit Testing 101 presented at ESRI Developer Summit, March 24th, 2009. This talk reviews the key concepts of unit testing, the technologies used by DTSAgile in out development projects.

You need some tests yo! Dave Bouwman // CTO // DTSAgile

the “big” ideas

prove code works

prove design works

catch regression

unit testing 101

Instantiate class under test… Call Method… Check Results… Call Method… Check Results…

good tests are… independent repeatable self-contained* professional

good tests are… focused


“unit testing on crack” Scott Hanselman www.hanselman.com

writing tests

simple methods with simple signatures mean simple tests

complex methods with complex signatures mean… complex tests

most ArcObjects applications fall in this category

for testing design we must

separation of concerns

a class has single purpose

stay inside its box

user interface (events + logic + data access)

private void ButtonOn_Click(){ //read values from controls //apply business logic //connect to database //update data //update interface }

user interface objects business objects data access objects

Private void ButtonOn_Click(){ //read values from controls //apply business logic //send changes to DAL //connect to database //update data //update interface }

n-tier architecture

user interface WPF/Silverlight objects business objects unit tests data access objects

design patterns yo

model view controller

ASP.NET MVC released!! http://asp.net/mvc

dependency management


1 created by the constructor

private IAccountRepository _accountRepository; private IFormsAuthentication _formsAuthentication; private ILogService _logger; public AccountController() { _accountRepository = new AccountRepository(_connectionString); _logger = new Logger(); _formsAuthentication = new FormsAuthentication(); }

what about testing

good tests are… independent repeatable self-contained* professional

“tight coupling” external dependencies in the tests

internal dependencies

and separate them

2 pass dependencies into the constructor

dependency injection

private IAccountRepository _accountRepository; private IFormsAuthentication _formsAuthentication; private ILogService _logger; public AccountController(IAccountRepository accountRepository, IFormsAuthentication formsAuthentication, ILogService logger) { _accountRepository = accountRepository; _formsAuthentication = formsAuthentication; _logger = logger; }

pushed the problem up a level

inversion of control

I need an AccountController! configuration Global.asax.cs

Castle Windsor Spring.NET mvccontrib IoC StructureMap Unity http://mvccontrib.codeplex.com

back to unit testing…

isolated testing

& mock fakes stubs

code you wrote generated on-the-fly

fake objects

stub/mock objects


rhinomocks http://ayende.com/projects/rhino-mocks.aspx

ArcMap development

not our box

separate logic from wiring

emulate events fromArcMap

my code sinks…

in ArcMap Business IEditEvents Shim Logic ArcMap

under test Business Test Logic

test your code not ESRI’s

ArcEngine Applications

it’s our box

design matters.

ArcGIS Server

testing Web ADF…

custom services

COM Utilities SOC COM Utility WebService ArcGIS Server

Server Object Extensions SOC SOE WebService ArcGIS Server

testable classes IServerObjectExtension COM COM SOE Utility Utility (ArcObjects) (ArcObjects)

but i’m too cool for COM…

jsunit D.O.H. Unit Testing FlexUnit Silverlight Harness

http://mbunit.com http://testdriven.net resources http://ASP.NET/mvc http://mvccontrib.codeplex.com http://castleproject.org http://ayende.com/projects/rhino-mocks.aspx

i’m in teh codez writin teztz!

and nao u can too!

http://blog.davebouwman.net dbouwman@dtsagile.com questions http://twitter.com/dbouwman http://slideshare.com/dbouwman

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Unit Testing 101 for the Non-Programmer

“Those who are enamored of practice without theory are like a pilot who goes into a ship without rudder or compass and never has any certainty where he ...
Read more

.net Unit Testing 101 - Delphi-PRAXiS

Links, slides and sample code from my .net Unit Testing 101 presentation.NUnit - unit testing library TestDriven.net - Visual Studio
Read more

Unit Testing 101 - Apache Cloudstack - Apache Software ...

Author: Alex Huang. The following is a FAQ on how to do write unit tests in cloud stack. Where are the unit tests? Within each source directory, there's ...
Read more

Unit Testing 101: Inversion Of Control - DZone DevOps

Join the DZone community and get the full member experience. The DevOps Zone is brought to you in partnership with New Relic. Download 5 Unsung Tools of ...
Read more

Unit Testing 101 // Speaker Deck

Unit testing can save you time, money, and frustration by helping you create a safety net around your software to guarantee its stability and quality.
Read more

Unit Testing 101 - novataig.net

Title: Unit Testing 101 Last modified by: r Document presentation format: Custom Other titles: Gill Sans Trebuchet MS Bold Trebuchet MS Title & Bullets ...
Read more

c# - Unit testing 101 - throwing an exception from within ...

I asked a related question. I want to give both those posters credit for the information that they provided based on my inadequate information in the post.
Read more

Unit Testing 101 by Clayton Peterson on Prezi

Intro to unit testing in visual studio ... Invited audience members will follow you as you navigate and present; People invited to a presentation do not ...
Read more

Unit Testing 101: Creating Flexible Test Code - DZone DevOps

Join the DZone community and get the full member experience. When going for test-driven development, we all know that the unit test code becomes critical ...
Read more