Post on 27-Jan-2015
description
transcript
some tests yo!You need
Dave Bouwman // CTO // DTSAgile
the “big” ideas
provecode
works
designprove
works
catchregression
101unit testing
Call Method…
Check Results…
Call Method…
Check Results…
Instantiate class under test…
independent
good tests are…
repeatable
self-contained*
professional
focused
good tests are…
tools!
“unit testingon crack”
Scott Hanselmanwww.hanselman.com
testswriting
simple methods
mean simple tests
with simple signatures
mean…
complex methodswith complex signatures
complex tests
most
category
ArcObjectsapplications
fall in this
design we mustfor testing
separationof concerns
singlea class has
purpose
stayinside
itsbox
(events + logic + data access)user interface
private void ButtonOn_Click(){
//read values from controls
//update interface
}
//apply business logic//connect to database//update data
objectsbusiness
objectsdata access
objectsuser interface
Private void ButtonOn_Click(){
//read values from controls
//update interface
}
//apply business logic//connect to database//update data
public class
}
//apply business logic//send changes to DAL
architecturen-tier
objectsbusiness
objectsdata access
objectsuser interface
testsunit
WPF/Silverlight
patterns yodesign
modelviewcontroller
released!!ASP.NET MVC
http://asp.net/mvc
managementdependency
dependencies
created
constructorby the
1
private IAccountRepository _accountRepository;private IFormsAuthentication _formsAuthentication;private ILogService _logger;
public AccountController(){
_accountRepository = new AccountRepository(_connectionString);
_logger = new Logger();_formsAuthentication = new FormsAuthentication();
}
what abouttesting
independent
good tests are…
repeatable
self-contained*
professional
“tight coupling”
externaldependencies
in thetests
dependenciesinternal
separateand
them
pass
constructorinto the
2dependencies
dependencyinjection
private IAccountRepository _accountRepository;private IFormsAuthentication _formsAuthentication;private ILogService _logger;
public AccountController(IAccountRepository accountRepository, IFormsAuthentication formsAuthentication, ILogService logger)
{_accountRepository = accountRepository;_formsAuthentication = formsAuthentication;_logger = logger;
}
problempushed
the
up alevel
of controlinversion
configurationGlobal.asax.cs
I need an AccountController!
mvccontrib IoC Spring.NET
StructureMap
Castle Windsor
Unity
http://mvccontrib.codeplex.com
unit testing…back to
isolatedtesting
&mockfakes
stubs
wrotecode you
on-the-flygenerated
objectsfake
objectsstub/mock
tools!
rhinomocks
http://ayende.com/projects/rhino-mocks.aspx
ArcMapdevelopment
notour
box
separatelogicfrom
wiring
ArcMapevents
emulate
from
sinks…my code
Shim
ArcMapin
ArcMap
IEditEventsBusiness
Logic
testunder
BusinessLogic
TestBusiness
Logic
yourtest
code
ESRI’snot
ArcEngineApplications
it’sour
box
designmatters.
ArcGISServer
Web ADF…testing
servicescustom
ArcGIS Server
WebService
SOC
COMUtility
COMUtilities
ArcGIS Server
WebService
SOC
SOE
ServerObjectExtensions
COMUtility
(ArcObjects)SOECOM
Utility(ArcObjects)
IServerObjectExtension
testableclasses
cool for COM…but i’m too
jsunit
FlexUnit
Silverlight Harness
D.O.H. Unit Testing
resourceshttp://mvccontrib.codeplex.com
http://castleproject.org
http://ASP.NET/mvc
http://ayende.com/projects/rhino-mocks.aspx
http://testdriven.net
http://mbunit.com
writin teztz!i’m in teh codez
can too!and nao u
questionshttp://twitter.com/dbouwman
http://slideshare.com/dbouwman
http://blog.davebouwman.net
dbouwman@dtsagile.com