A second look at Unit Testing with Roy Osherove at Microsoft Swit
-
Upload
roy-osherove -
Category
Technology
-
view
753 -
download
1
description
Transcript of A second look at Unit Testing with Roy Osherove at Microsoft Swit
![Page 2: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/2.jpg)
![Page 3: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/3.jpg)
• Unit Of Work• Setup Methods
• Constrained vs. Unconstrained Isolation
Frameworks• Principles of Good Isolation Frameworks
• Faking Deep Legacy is OK• Six Influence Forces
• Beautiful Builds
![Page 4: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/4.jpg)
![Page 5: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/5.jpg)
![Page 6: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/6.jpg)
Unit
Of
Work
Production Code
Unit Of Work
Return Value/Exceptio
n
Noticeable State Change
3rd Party call
Public API
Test
![Page 7: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/7.jpg)
Production Code
Unit Of Work
Return Value/Exceptio
n
Public API
Assert Test
![Page 8: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/8.jpg)
![Page 9: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/9.jpg)
Production Code
Unit Of Work
Noticeable State Change
Test
Public API
Ass
ert
![Page 10: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/10.jpg)
![Page 11: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/11.jpg)
Noti
ceable
Sys
tem
Behavi
or
Change
Noticeable by a user
of the public API, at the same level of
the entry point that made the change.
ACT and ASSERT on the same level of APIs.
![Page 12: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/12.jpg)
Production Code
Unit Of Work
3rd Party call
Test
Public API As
sert
3rd Party
Unit Of Work
![Page 13: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/13.jpg)
Production Code
Unit Of Work
3rd Party call
Test
Public API As
sert
3rd Party
Unit Of Work
Mock
![Page 14: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/14.jpg)
![Page 15: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/15.jpg)
Nam
ing b
y U
nit
O
f W
ork
UnitOfWork_Input_Expect
edOutput
UnitOfWork_LogicalAction
_ExpectedChangeInBeha
vior
UnitOfWork_ActionOrInpu
t_ExepectedCallToThirdPa
rty
![Page 16: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/16.jpg)
Nam
ing b
y U
nit
O
f W
ork
Addition_PositiveNumbers
_ReturnsSum() Addition_WhenCalled_Res
etsTheNextSum() Addition_NegativeNumber
s_CallsLogger()
![Page 17: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/17.jpg)
Setu
p M
eth
ods
![Page 18: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/18.jpg)
Isola
tion
Fram
ew
ork
s
Constrained vs. Unconstrained
![Page 19: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/19.jpg)
![Page 20: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/20.jpg)
Recu
rsiv
e F
ake
s &
C
hain
ed
Exp
ect
ati
ons
Recursive is not explicit: Person.Manager.Manager is
already a fake instance without asking for it
Chained Expectations are explicit Mock.Arrange(() => Person.Manager.Manager)
.Returns(fakeManager)
![Page 21: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/21.jpg)
Team Agile - All rights
reserved
![Page 22: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/22.jpg)
Unco
nst
rain
ed
![Page 23: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/23.jpg)
Const
rain
ed
![Page 24: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/24.jpg)
Goodbye
R
hin
oM
ock
s Hello FakeItEasy,
NSubstitute
![Page 25: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/25.jpg)
Valu
es
of
a G
ood
Isola
tion F
ram
ew
ork
Simple Single point of entry Easy to remember Intellisense Guidance
Test Robustness Recursive Fakes non strict by default
Helpful Helpful Error Messages
No surprisesTeam Agile - All rights
reserved
![Page 26: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/26.jpg)
Rspec style is ok
Assert multiple results on
same unit of work
![Page 27: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/27.jpg)
![Page 28: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/28.jpg)
![Page 29: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/29.jpg)
![Page 30: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/30.jpg)
LEGACY CODEFaking Deep
System Internals is OKExample - SilverUnit
![Page 31: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/31.jpg)
Cross Cutting Fakes
![Page 32: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/32.jpg)
Old code
![Page 33: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/33.jpg)
Old code FakeNewcode
CROSS CUTTING FAKES
![Page 34: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/34.jpg)
![Page 35: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/35.jpg)
Impacting
Change
![Page 36: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/36.jpg)
6 in
fluence
fo
rces
Personal Ability Motivation Social Ability Motivation Environmental Ability Motivation
![Page 37: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/37.jpg)
Anoth
er
book?
![Page 38: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/38.jpg)
Tools
Pex – yes Moles (ms fakes) – NO
JustMock - Maybe Nuget – YES Chocolatey – YES
TeamCity – YES FinalBuilder – YES Ruby and Rake – Maybe
Amazon AWS agent hosting –
YES Git for very small commits -
YES
![Page 39: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/39.jpg)
![Page 40: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/40.jpg)
Build and
Delivery
![Page 41: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/41.jpg)
![Page 42: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/42.jpg)
Build Patterns
![Page 43: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/43.jpg)
Build
Scr
ipt
Inje
ctio
n Allow version aware builds Build scripts are part
of source control Build configurations on
the CI server are dumb
triggers
![Page 44: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/44.jpg)
Ext
ract
Scr
ipt
Extract Script
![Page 45: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/45.jpg)
Build Chain Triggers
Triggered by checkin
Triggered by end of previous
Manual
Manual
Build Chaining
![Page 46: A second look at Unit Testing with Roy Osherove at Microsoft Swit](https://reader034.fdocuments.in/reader034/viewer/2022051322/5453f4fdaf7959856d8b5451/html5/thumbnails/46.jpg)
• Unit Of Work• Setup Methods
• Constrained vs. Unconstrained Isolation
Frameworks• Principles of Good Isolation Frameworks
• Faking Deep Legacy is OK• Six Influence Forces
• Beautiful Builds