Testing and Integration !"#$%&'$(%)(*+ - - PowerPoint PPT Presentation

testing and integration
SMART_READER_LITE
LIVE PREVIEW

Testing and Integration !"#$%&'$(%)(*+ - - PowerPoint PPT Presentation

Testing and Integration !"#$%&'$(%)(*+ ,-(*.#$*/-&,01$0((#$01&/02&!3456.(#&7*$(0*( 8(/#0$01&7*$(0*(% 93#.":(%.(#0&;0$<(#%$.= 1 Thursday, October 25, 2012 Readings >"(%(&%-$2(%


slide-1
SLIDE 1

1

Testing and Integration

!"#$%&'$(%)(*+

,-(*.#$*/-&,01$0((#$01&/02&!3456.(#&7*$(0*( 8(/#0$01&7*$(0*(% 93#.":(%.(#0&;0$<(#%$.=

Thursday, October 25, 2012

slide-2
SLIDE 2

Readings

>"(%(&%-$2(% !"#$%&'(#$)*+,-*'?&!"/5.(#%&@AB&@CB&@D "E5?FF2/003#."G0(.F$0.#326*$01H)22F "E5?FF4/#I0J3:-(#G*34F/#I*-(%F 43*+%K#(0.7.6)%G".4- "E5?FF4/#I0J3:-(#G*34F/#I*-(%F *30I0636%L0.(1#/I30G".4-

Thursday, October 25, 2012

slide-3
SLIDE 3

Signs a module is test-deficient

!"/01(%&.3&/&4326-(&./+(&.:$*(&/%&-301&.3&2()61&/02& 2(5-3=&/%&3."(#&4326-(% !"/01(%&.3&/&4326-(&)#3+(&."(&/55&43#(&."/0&.:$*( K&4326-(M%&*32(&$%&0(<(#&2(-(.(2&3#&432$N(2B&30-=& /22(2&.3G OP(&230M.&.36*"&."/.&4326-(G&L.M%&.33&$453#./0.&.3& #$%+&)#(/+$01GO

Thursday, October 25, 2012

slide-4
SLIDE 4

Types and purposes of testing

K**(5./0*(&.(%.% Q6%.H$0HI4(&#(R6$#(4(0.%&J3#&(/*"&6%(#&%.3#= ;0$.&.(%.% (S(*6./)-(&23*64(0./I30&3J&."(&$0.(02(2&)("/<$3#&3J& (<(#=&60$.&3J&*32( #(1#(%%$30&.(%.% /&#(1#(%%$30&.(%.&*/.*"(%&*"/01(%&."/.&)#(/+&5#(<$36%-=& :3#+$01&*32( L0.(1#/I30&.(%.% *30N#4/I30&."/.&.(%.(2&4326-(%&:3#+&.31(."(#&*3##(*.-=

Thursday, October 25, 2012

slide-5
SLIDE 5

Acceptance tests

K&6%(#&*/0&/22& /0&$.(4&.3&."(& %"355$01&*/#.

Thursday, October 25, 2012

slide-6
SLIDE 6

When I add an item to my shopping cart Then my shopping cart page contains the item

Acceptance tests

K&6%(#&*/0&/22& /0&$.(4&.3&."(& %"355$01&*/#.

Thursday, October 25, 2012

slide-7
SLIDE 7

When I add an item to my shopping cart Then my shopping cart page contains the item

Acceptance tests

K&6%(#&*/0&/22& /0&$.(4&.3&."(& %"355$01&*/#.

P/$.T&U3&."(=& "/<(&.3&)(&

  • 311(2&$0V

Thursday, October 25, 2012

slide-8
SLIDE 8

Acceptance tests

Given I am not logged in When I add an item to my shopping cart Then my shopping cart page contains the item

K&6%(#&*/0&/22& /0&$.(4&.3&."(& %"355$01&*/#.

Given I am logged in When I add an item to my shopping cart Then my shopping cart page contains the item

P/$.T&U3&."(=& "/<(&.3&)(&

  • 311(2&$0V

Thursday, October 25, 2012

slide-9
SLIDE 9

Acceptance tests

Given my shopping cart page contains items and I am not logged in When I log in Then my shopping cart page has the same items as before Given I am not logged in When I add an item to my shopping cart Then my shopping cart page contains the item

K&6%(#&*/0&/22& /0&$.(4&.3&."(& %"355$01&*/#.

Given I am logged in When I add an item to my shopping cart Then my shopping cart page contains the item

P/$.T&U3&."(=& "/<(&.3&)(&

  • 311(2&$0V

Thursday, October 25, 2012

slide-10
SLIDE 10

Acceptance tests

!-$(0.&/02&2(<(-35(#%&2(N0(&/**(5./0*(&.(%.%&J3#& (/*"&6%(#&%.3#=& *6##(0.&$.(#/I30&%.3#$(%&30-=T >=5$*/--=&/&0(:&5#326*.&:$--&(02&65&:$."&23W(0%&.3&/& "602#(2% X/0=&.33-%&(S$%.&.3&4/+(&."(%(&43#(&#(/2/)-(&)=& *-$(0.% !6*64)(#?&"E5?FF*6+(%G$0J3F Y$.0(%%(?&"E5?FFN.0(%%(G3#1F

Thursday, October 25, 2012

slide-11
SLIDE 11

Unit tests

!"#$%&'()%*'+,-./0)1,23$%*3.)456 7 '''''-.4%18'8))*/0)1,'9':5;<=6'>>>?;<;<:@ '''''-.4%18'#3*/0)1,'9':>>>';<: '''''/0)1,23$%*3.)4'(3$%*3.)4'9'1,A'/0)1,23$%*3.)456@ '''''B--,4.CD-+4",5(3$%*3.)4CD-23$%*58))*/0)1,66@ '''''B--,4.CD-E3$-,5(3$%*3.)4CD-23$%*5#3*/0)1,66@ F

http://stackoverflow.com/questions/4910138/unit-test-examples

Thursday, October 25, 2012

slide-12
SLIDE 12

Unit tests

P#$E(0&)=&2(<(-35(#% >(%.&60$.%&ZJ60*I30%B&4(."32%B&*-/%%(%[ 9((2&.3&)(&064(#36%B&J/%.B&/6.34/.(2 $J&03.&J/%.&/02&/6.34/.(2B&."(=&:30M.&)(&#60 Y#/4(:3#+%&J3#&:#$I01&/02&#600$01&60$.&.(%.%&(S$%.& J3#&/--&432(#0&5#31#/44$01&-/016/1(% U30M.&:#$.(&=36#&3:0&J#/4(:3#+T

Thursday, October 25, 2012

slide-13
SLIDE 13

Test-driven Development (TDD)

P"(0&:#$I01&/&0(:&60$.&3J&*32( :#$.(&.(%.&*32(&J3#&$.&N#%. #60&/--&."(&60$.&.(%.%& 4/+(&%6#(&30-=&."(&#$1".&0(:&30(%&J/$- P#$.(&Q6%.&(0361"&*32(&.3&4/+(&/--&.(%.%&5/%% '(5(/.

Thursday, October 25, 2012

slide-14
SLIDE 14

Integration tests

public class OrderStateTester extends TestCase { private static String TALISKER = "Talisker"; private Warehouse warehouse = new WarehouseImpl(); protected void setUp() throws Exception { warehouse.add(TALISKER, 50); } public void testOrderIsFilledIfEnoughInWarehouse() { Order order = new Order(TALISKER, 50);

  • rder.fill(warehouse);

assertTrue(order.isFilled()); assertEquals(0, warehouse.getInventory(TALISKER)); } public void testOrderNotFilledIfNotEnoughInWarehouse() { Order order = new Order(TALISKER, 51);

  • rder.fill(warehouse);

assertFalse(order.isFilled()); assertEquals(50, warehouse.getInventory(TALISKER)); } }

This tests the business logic for an order page making calls to a warehouse database object

  • rder objects and

warehouse data must update consistently

Thursday, October 25, 2012

slide-15
SLIDE 15

Integration tests

P#$E(0&)=&2(<(-35(#% >(%.&*3--(*I30%&3J&*34460$*/I01&4326-(% %"36-2&$0*-62(&/--&4/Q3#&*34460$*/I30&5/."% K#(&.=5$*/--=&J(:(#&/02&%-3:(#&."/0&60$.&.(%.% Y/$-6#(&%"36-2&-(/2&.3&0(:&60$.&.(%.%B&(G1GB&$J&4326-(&\& J/$-%&:"(0&*/--(2&)=&K $J&K&%(0.&)/2&2/./B&/22&60$.&.(%.%&30&K&.3&*/.*"&."/. $J&\&J/$-(2&.3&"/02-(&1332&2/./B&/22&60$.&.(%.%&30&\&.3& */.*"&."/.

Thursday, October 25, 2012

slide-16
SLIDE 16

Continuous Integration

]0&(<(#=&652/.(&.3&."(&*32(&#(53%$.3#=? \6$-2&/02&2(5-3=&.3&/&5#326*I30&(0<$#304(0. '60&/--&.(%.%&30&."/.&2(5-3=4(0. 7.35&2(<(-354(0.&$J&/0=."$01&)#(/+%&3#&/0=&.(%.& J/$-%

Thursday, October 25, 2012

slide-17
SLIDE 17

>(%I01&$%& "/#2T

Thursday, October 25, 2012

slide-18
SLIDE 18

Incremental TDD

7./#.&%4/-- P#$.(&/0&K',&P,&;^V&.(%.&& _(#$N(%&=36&2$20M.&Q6%.&*345-(.(-=&)#(/+&."(& %=%.(4 L0<3*/)-(&:$."&30(&*344/02 K%&."$01%&)#(/+B&/22&.(%.%&.3&."$%&."/.&:36-2&"/<(& */61".&."(&)#(/+/1(&65&J#30.G P"(0&%34(."$01&$%&*345-$*/.(2B&:#$.(&.(%.%&)(J3#(& ."$01%&)#(/+&.3&"(-5&=36&."$0+&."#361"&."(&2(%$10G

Thursday, October 25, 2012

slide-19
SLIDE 19

Document bugs in tests

P"(0&/&)61&"/55(0%B&230M.&NS&$.G Y$#%.B&:#$.(&/&60$.&.(%.&."/.&#(-$/)-=&#(5#326*(%&."(& )61G ;0I-&=36&*/0B&=36&230M.&602(#%./02&."(&)61 93:&:#$.(&*32(&.3&5/%%&."(&.(%.&/02&NS&."(&)61G

Thursday, October 25, 2012

slide-20
SLIDE 20

Testing web pages

Thursday, October 25, 2012

slide-21
SLIDE 21

Browser testing, Part 1

;%(&."(&#$1".&U]!>`^, "E5?FF"%$<30(0G$+$GNF23*.=5(Fa*"33%$01 K<3$2&R6$#+%&432(&/.&/--&*3%.%T "E5?FF:::G*%G.6.GNFbQ+3#5(-/FR6$#+%H432(G".4- _/-$2/.(&=36#&c>X8&/02&!77 d((5&=36#&)#3:%(#&!30%3-(&35(0G&X/+(&%6#(&=36#&5/1(%&1(0(#/.(& 03&(##3#%&3#&:/#0$01%G '60&/&</-$2/.3#&J3#&c>X8&/02&!77&)(J3#(&*"(*+$0G "E5?FF</-$2/.3#G:eG3#1F "E5?FFQ$1%/:G:eG3#1F*%%H</-$2/.3#F

Thursday, October 25, 2012

slide-22
SLIDE 22

Browser testing, Part 2

$0%./--&46-I5-(&)#3:%(#% /.&-(/%.&L,B&Y$#(J3SB&7/J/#$B&!"#34( ."(#(&/#(&:/=%&.3&#60&46-I5-(&<(#%$30%&3J&L,B& (G1GB "E5?FF6I-6G*34FL,!3--(*I30F <$%6/--=&$0%5(*.&=36#&5/1(%&/.&-(/%.&30*(&/&:((+&$0& (<(#=&)#3:%(#

Thursday, October 25, 2012

slide-23
SLIDE 23

Browser testing, Part 3

Thursday, October 25, 2012

slide-24
SLIDE 24

Browser testing, Part 3

;%(&/&:()&60$.&.(%I01&.33-

Thursday, October 25, 2012

slide-25
SLIDE 25

Browser testing, Part 3

;%(&/&:()&60$.&.(%I01&.33-

U3(%&03.&0((2&.3&)(&:#$E(0&$0&."(& %/4(&-/016/1(&/%&=36#&%(#<(#T

Thursday, October 25, 2012

slide-26
SLIDE 26

Browser testing, Part 3

;%(&/&:()&60$.&.(%I01&.33-

U3(%&03.&0((2&.3&)(&:#$E(0&$0&."(& %/4(&-/016/1(&/%&=36#&%(#<(#T "E5?FF%(-(0$64"RG3#1F "E5?FFQ:()60$.G%36#*(J3#1(G0(.F "E5?FF:::G%3f:/#(R/.(%.G*34F R/.:()@G".4-aY;9!

Thursday, October 25, 2012

slide-27
SLIDE 27

Continuous Integration

Thursday, October 25, 2012

slide-28
SLIDE 28

Continuous Integration Server

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-29
SLIDE 29

What can go worng?

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-30
SLIDE 30

What can go worng?

repo access issues

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-31
SLIDE 31

What can go worng?

repo access issues

  • ut of date

config info

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-32
SLIDE 32

What can go worng?

repo access issues

  • ut of date

config info build env differences

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-33
SLIDE 33

What can go worng?

repo access issues

  • ut of date

config info test env (server, emulator) differences build env differences

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-34
SLIDE 34

What can go worng?

repo access issues

  • ut of date

config info test env (server, emulator) differences test output parsing issues build env differences

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-35
SLIDE 35

What can go worng?

repo access issues

  • ut of date

config info test env (server, emulator) differences email config issues test output parsing issues build env differences

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-36
SLIDE 36

What can go worng?

repo access issues

  • ut of date

config info test env (server, emulator) differences dev server access issues email config issues test output parsing issues build env differences

http://www.javaworld.com/javaworld/jw-12-2008/jw-12-hudson-ci.html

Thursday, October 25, 2012

slide-37
SLIDE 37

Continuous Integration

7(.65&*345-$*/.(2&)6.&:3#."&$.G ]0*(&$0&5-/*(B&$.&%6553#.%&/02& (0*36#/1(%&4/0=&)(%.&5#/*I*(% .(%.H2#$<(0&2(<(-354(0. *30I0636%&2(5-3=4(0. .#/0%5/#(0.&2(<(-354(0.&%./.6% %"/#(2&*32(&3:0(#%"$5 \6.&%(.65&'.&*345-$*/.(2

Thursday, October 25, 2012

slide-38
SLIDE 38

!L&$%&"/#2T

Thursday, October 25, 2012

slide-39
SLIDE 39

Incremental CI

7./#.&%4/-- Y$#%.&/6.34/.(&=36#&2(5-3=&/02&.(%.G K&30(H*344/02&%*#$5.&."/.&)6$-2%&=36#&/55B&*35$(%& .3&/&%(#<(#B&/02&#60%&=36#&30(H*344/02&K',&P,& ;^V& X/+(&$.&/&"/)$.&.3&#60&$.&:"(0(<(#&=36&65-3/2&*32(G P"(0&."/.&)(*34(%&(/%=B&=36M#(&#(/2=&.3&.6#0&."(& Q3)&3<(#&.3&/&!L&%(#<(#G

Thursday, October 25, 2012

slide-40
SLIDE 40

Continuous Integration Practices

]0(&%36#*(&#(53%$.3#= K6.34/.(2&%(-JH.(%I01&)6$-2% U/$-=&*344$.%B&J/%.&)6$-2% !344$.%&)6$-2&/55-$*/I30 >(%.%&#60&$0&5#326*I30&(0<$#304(0. ,/%=&/**(%%&.3&(S(*6./)-(B&)6$-2&%./.6% K6.34/.(2&2(5-3=4(0.

http://martinfowler.com/articles/continuousIntegration.html

Thursday, October 25, 2012

slide-41
SLIDE 41

X$0$4$W(&)#/0*"(% L0*-62(&(<(#=."$01&0((2(2&.3&)6$-2? .(%.&%*#$5.% 5#35(#I(%&N-(% 2/./)/%(&%*"(4/ $0%./--&%*#$5.% ."$#2&5/#.=&-$)#/#$(%

One source repository

Thursday, October 25, 2012

slide-42
SLIDE 42

X$0$4$W(&)#/0*"(% L0*-62(&(<(#=."$01&0((2(2&.3&)6$-2? .(%.&%*#$5.% 5#35(#I(%&N-(% 2/./)/%(&%*"(4/ $0%./--&%*#$5.% ."$#2&5/#.=&-$)#/#$(%

OLM<(&+03:0&5#3Q(*.%&."/.&*"(*+&."($#& *345$-(#%&$0.3&."(&#(53%$.3#=GO

One source repository

Thursday, October 25, 2012

slide-43
SLIDE 43

X$0$4$W(&)#/0*"(% L0*-62(&(<(#=."$01&0((2(2&.3&)6$-2? .(%.&%*#$5.% 5#35(#I(%&N-(% 2/./)/%(&%*"(4/ $0%./--&%*#$5.% ."$#2&5/#.=&-$)#/#$(%

OLM<(&+03:0&5#3Q(*.%&."/.&*"(*+&."($#& *345$-(#%&$0.3&."(&#(53%$.3#=GO

O`36&%"36-2&)(&/)-(&.3&:/-+&65&.3&."(&5#3Q(*.&:$."&/&<$#1$0& 4/*"$0(B&23&/&*"(*+36.B&/02&)(&/)-(&.3&J6--=&)6$-2&."(&%=%.(4GO

One source repository

Thursday, October 25, 2012

slide-44
SLIDE 44

K&%(5/#/.(&%./02H/-30(&)6$-2&%*#$5. 93.&=36#&LU,&O)6$-2&5#3Q(*.O \6$-2&%*#$5. *345$-(%&0(:&*32(&/02&)6$-2%&/55-$*/I30 #60%&/--&.(%.% .(%.&J/$-6#(&$%&%.35%&)6$-2 X/0=&.33-%? X/+(B&K0.B&'/+(B&X7\6$-2B&g#/2-(B&GGG "E5?FF(0G:$+$5(2$/G3#1F:$+$F 8$%.h3Jh)6$-2h/6.34/I30h%3f:/#(

Automated self-testing builds

Thursday, October 25, 2012

slide-45
SLIDE 45

,<(#=30(&*344$.%&30*(&/&2/=B&3#&43#(T U3&-3*/-&Z5#$</.([&)6$-2&)(J3#(&*344$. ;52/.(&:3#+$01&*35=&)(J3#(&-3*/-&)6$-2 7-$*(&./%+%&$0.3&%4/--&*344$E/)-(&)$.% Y/%.&)6$-2 @i&4$06.(%&3#&-(%% LJ&)6$-2&1(.%&.33&-301B&6%(&%./1(2&)6$-2% *344$.&)6$-2&#60%&60$.&.(%.%B&:$."&43*+&3)Q(*.% %(*302/#=&)6$-2&#60%&/**(5./0*(&/02&$0.(1#/I30&.(%.%& :"(0&*344$.&)6$-2&%6**((2%

Daily commits, fast builds

Thursday, October 25, 2012

slide-46
SLIDE 46

,<(#=&*344$.&#()6$-2%&."(&4/$0-$0(&30&/&2(2$*/.(2& $0.(1#/I30&4/*"$0( X/0=&!30I0636%&L0.(1#/I30&%(#<(#%&/</$-/)-(&03: c62%30&F&j(0+$0%&Z$.M%&/&-301&%.3#=[ !#6$%(!30.#3-&Zj/</&/02&'6)=&<(#%$30%[ g3&ZJ3#4(#-=&!#6$%([ "E5?FF(0G:$+$5(2$/G3#1F:$+$F !345/#$%30h3Jh!30I0636%hL0.(1#/I30h73f:/#(

Commits build application

Thursday, October 25, 2012

slide-47
SLIDE 47

U30M.&/%%64(&/--&P$023:%&F&8$06S&F&X/*]7&4/*"$0(%&/#(& ."(&%/4( _$#.6/-$W/I30&.3&."(&#(%*6( (G1GB&_$#.6/-\3S "E5?FF:::G<$#.6/-)3SG3#1F !L&%(#<(#&*#(/.(%&/&*-30(&3J&."(&2(5-3=4(0.&(0<$#304(0. "E5?FF2#0$*:$--$/4%G*34FAi@iF@@FikF4/+$01H*$H (/%$(#H.3H23H."/0H03.H.3H:$."H"62%30H*$H/02H</1#/0.F

Test in the production environment

Thursday, October 25, 2012

slide-48
SLIDE 48

!L&2(5-3=%&.3&56)-$*$W(2&-3*/I30 !L&2$%5-/=%&#(%6-.%&56)-$*-=&

Easy access to executable and status

Thursday, October 25, 2012

slide-49
SLIDE 49

!L&2(5-3=%&.3&56)-$*$W(2&-3*/I30 !L&2$%5-/=%&#(%6-.%&56)-$*-=&

Easy access to executable and status

Thursday, October 25, 2012

slide-50
SLIDE 50

!L&2(5-3=%&.3&56)-$*$W(2&-3*/I30 !L&2$%5-/=%&#(%6-.%&56)-$*-=&

BUILD FAILED file:C:/work/dms/builds/ checkout/dms/build.xml:77: Tests failed! Check test reports.

Easy access to executable and status

Thursday, October 25, 2012

slide-51
SLIDE 51

!L&2(5-3=%&.3&56)-$*$W(2&-3*/I30 !L&2$%5-/=%&#(%6-.%&56)-$*-=&

BUILD FAILED file:C:/work/dms/builds/ checkout/dms/build.xml:77: Tests failed! Check test reports.

http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/ Monitor/Devices/BubbleBubbleBuildsInTrouble.rdoc

Easy access to executable and status

Thursday, October 25, 2012

slide-52
SLIDE 52

]0(&%.(5&2(5-3=&.3&*-$(0.&4/*"$0(% "E5?FF.30$G3#1FAi@iFiDF@kF$0H5#/$%(H3JH*30I0636%H2(5-3=4(0.H ."(H:3#25#(%%H*34H%.3#=F "E5?FF#/2/#G3#($--=G*34FAiikFieF*30I0636%H2(5-3=4(0.HDH (/%G".4- "E5?FF:::G-$4$.(2:$5%3*$(.=G*"F(0F*/%(H%.62=G".4- 1#(/.&-33+&/.&Y/*()33+&"$%.3#=&/02&2(<&5#3*(%%(% "E5?FF:::G$0J3RG*34F5#(%(0./I30%F!30I0636%HU(5-3=4(0.HDiH >$4(%H/HU/=

Automated deployment

Thursday, October 25, 2012

slide-53
SLIDE 53

]0(&%.(5&2(5-3=&.3&*-$(0.&4/*"$0(% "E5?FF.30$G3#1FAi@iFiDF@kF$0H5#/$%(H3JH*30I0636%H2(5-3=4(0.H ."(H:3#25#(%%H*34H%.3#=F "E5?FF#/2/#G3#($--=G*34FAiikFieF*30I0636%H2(5-3=4(0.HDH (/%G".4- "E5?FF:::G-$4$.(2:$5%3*$(.=G*"F(0F*/%(H%.62=G".4- 1#(/.&-33+&/.&Y/*()33+&"$%.3#=&/02&2(<&5#3*(%%(% "E5?FF:::G$0J3RG*34F5#(%(0./I30%F!30I0636%HU(5-3=4(0.HDiH >$4(%H/HU/= O,<(#=30(&$0&36#&*345/0=&"/%&/**(%%&.3&/&2(5-3=&)6E30& ."/.&#(-(/%(%&."(&-/.(%.&*"(*+(2&$0&*32(&.3&/)36.&Cii& 5#326*I30&%(#<(#%&$0&36#&:()&I(#&$0&-(%%&."/0&ei&%(*302%GO >30$&7*"0($2(#B&P3#2^#(%%

Automated deployment

Thursday, October 25, 2012

slide-54
SLIDE 54

Resources

>"(&2(N0$I30&/02&#(/%30%&J3#&!30I0636%&L0.(1#/I30& /#(&1$<(0&$0&!"/5.(#&@D&3J&>"(&K1$-(&7/46#/$&)33+G >"(&%(*I30&30&!L&$%&)/%(2&30 "E5?FF4/#I0J3:-(#G*34F/#I*-(%F *30I0636%L0.(1#/I30G".4- >"$%&$%&/&#(<$%$30&3J&30(&3J&."(&N#%.&/#I*-(%&30& !30I0636%&L0.(1#/I30&Z!L[&)=&X/E"(:&Y3(44(-& /02&X/#I0&Y3:-(#& 93.(?&X/#I0&Y3:-(#&$%&/-%3&."(&J/."(#&3J&#(J/*.3#$01

Thursday, October 25, 2012

slide-55
SLIDE 55

CI Server Setup Help

X/0=&.6.3#$/-%&36.&."(#(B&J3#&%(l01&65&!L&%(#<(#%&:$."&'6)=&30& '/$-%B&UQ/013B&^c^B&j/</%*#$5.B&GGG&,G1GB "E5?FF%3-$./#=1((+G*34FQ/</F"62%30H*$H%(#<(#H/H%.(5H)=H %.(5H16$2(H5/#.H$ "E5?FF*Q3"/0%(0G03F(0FQ/</%*#$5.F Q/</%*#$5.h*30I0636%h$0.(1#/I30h:$."h"62%30h/02hQ%.(%. 2#$<(# Zj(0+$0%&/02&c62%30&/#(&)/%$*/--=&."(&%/4([ 75#$01&,,!7&ekC&%.62(0.H:#$E(0&16$2(%? "E5?FF:::G*%G03#.":(%.(#0G(26F/*/2(4$*%F*36#%(%FekCF *$H%(#<(#F

Thursday, October 25, 2012

slide-56
SLIDE 56

Testing: the fine points

Thursday, October 25, 2012

slide-57
SLIDE 57

My first “Aha!” moment occurred as I was being shown a deceptively simple utility called agiledox, written by my colleague, Chris Stevenson. It takes a JUnit test class and prints out the method names as plain sentences, so a test case that looks like this:

!"#$%&'&$'(('G"-.)H,4I))J"!+,-.')*+),-('+,-.G3-,'7 ''''.,-.E%1*-G"-.)H,4KLD*56'7 ''''''''CCC ''''F ''''.,-.E3%$-E)4M"!$%&3.,G"-.)H,4-56'7 ''''''''CCC ''''F ''''CCC F

becomes

G"-.)H,4I))J"! ?'N%1*-'&"-.)H,4'#L'%* ?'N3%$-'N)4'*"!$%&3.,'&"-.)H,4- ?'CCC

[Developers] found that when they wrote the method name in the language of the business domain,the generated documents made sense to business users, analysts, and testers.

Test names should be sentences

http://dannorth.net/introducing-bdd/

Thursday, October 25, 2012

slide-58
SLIDE 58

Test naming

testm,<(0.nm!3##(*.'(%6-.n() .(%.K**360.% .(%.U(53%$. .(%.U(53%$.o(#3 .(%.U(53%$.o(#3L%,##3# .(%.U(53%$.o(#38(/<(%\/-/0*(;0*"/01(2 g#(/.(#&*-/#$.=&.3&/--&#(/2(#% ,/%=&#(<$(:&.3&%((&:"/.M%&)((0&.(%.(2 ,0*36#/1(%&30(&.(%.&.3&/&.(%.

Thursday, October 25, 2012

slide-59
SLIDE 59

Only test functions worth testing

]0-=&.(%.&56)-$*&J60*I30% ^#$</.(&J60*I30%&*/0&/02&%"36-2&)(&/)-(&.3&*"/01(& J#((-= ^#$</.(&J60*I30&)61%&30-=&4/E(#&:"(0&."(=&/p(*.& 56)-$*&)("/<$3# ]0-=&.(%.&-31$*/--=&030H.#$<$/-&J60*I30% U30M.&:#$.(&.(%.%&J3#&/**(%%3#%B&(G1GB&1(.'/2$6%Z[B& %(.9/4(Z[B&GGG&60-(%%&."(#(M%&43#(&*32(&."/0& 1(l01F%(l01&/0&$0.(#0/-&</#$/)-(

Thursday, October 25, 2012

slide-60
SLIDE 60

A Unit Test Challenge

;0$.&.(%.% %"36-2&)(&064(#36%B&J/%.B&/6.34/.(2 %"36-2&.(%.&."(&60$.B&03.&3."(#&*-/%%(%& %"36-2&03.&*#3%%&4326-(&)3602/#$(% c3:&*/0&=36&60$.&.(%.&*32(&:$."36.&4/+$01&$0.(1#/I30& .(%.%V */--$01&*32(&$0&3."(#&4326-(% <(#=&%-3:B&(G1GB&2/./)/%(&*300(*I30% */--$01&*32(&."/.&4/=&03.&(S$%.&=(.

Thursday, October 25, 2012

slide-61
SLIDE 61

Solution: Mock objects

K&43*+&3)Q(*.&$4$./.(%&/0&3)Q(*.&J#34&/03."(#&*-/%% K&43*+&3)Q(*.&5#3<$2(%&.:3&+(=&J(/.6#(%? $.&*/0&)(&6%(2&-$+(&/0&3)Q(*.&0((2(2&)=&."(&60$.&602(#&.(%. $.&*/0&#(*3#2&/02&<(#$J=&."/.&."(&43*+&3)Q(*.&:/%& *3##(*.-=&6%(2&)=&."(&60$.&602(#&.(%. L45-(4(0I01&43*+&3)Q(*.%&)=&"/02&*/0&)(&.(2$36%&J3#& *-/%%(%&:$."&4/0=&4(."32% X3*+&-$)#/#$(%&5#3<$2(&.33-%&J3#&4/+$01&43*+%&$0&Q6%.&/&J(:& %.(5%

Thursday, October 25, 2012

slide-62
SLIDE 62

Preparing for mock objects

L0&-/016/1(%&-$+(&j/</&."/.&2$%I016$%"&*-/%%(%&Z*32([&J#34& $0.(#J/*(%&ZK^L%[B&#(5-/*(&*-/%%(%&.3&)(&43*+(2&:$."& $0.(#J/*(%G&Zg332&5#/*I*(&$0&1(0(#/-[

public class Warehouse { public int getInventory(int unitId) { ...db query... } ... } public interface Warehouse { public int getInventory(int unitId) ... } public class WarehouseImpl implements Warehouse { public int getInventory(int unitId) { ...db query... } ... }

Thursday, October 25, 2012

slide-63
SLIDE 63

jMock 1: using Mock class

public class OrderTester extends TestCase { private Warehouse warehouse = new WarehouseImpl(); ... public void testOrderIsFilledIfEnoughInWarehouse() { Order order = new Order(TALISKER, 50);

  • rder.fill(warehouse);

assertTrue(order.isFilled()); assertEquals(0, warehouse.getInventory(TALISKER)); } public class OrderTester extends MockObjectTestCase { ... public void testOrderIsFilledIfEnoughInWarehouse() { Order order = new Order(TALISKER, 50); Mock warehouseMock = new Mock(Warehouse.class); ...

  • rder.fill((Warehouse) warehouseMock.proxy());

assertTrue(order.isFilled()); warehouseMock.verify(); }

http://martinfowler.com/articles/mocksArentStubs.html

create a mock Warehouse verify the mock's expectations pass the mock to Order

Thursday, October 25, 2012

slide-64
SLIDE 64

jMock 1: using mock() method

public class OrderTester extends TestCase { private Warehouse warehouse = new WarehouseImpl(); ... public void testOrderNotFilledIfNotEnoughInWarehouse() { Order order = new Order(TALISKER, 51);

  • rder.fill(warehouse);

assertFalse(order.isFilled()); assertEquals(50, warehouse.getInventory(TALISKER)); } public class OrderTester extends MockObjectTestCase { ... public void testOrderNotFilledIfNotEnoughInWarehouse() { Order order = new Order(TALISKER, 51); Mock warehouse = mock(Warehouse.class); ...

  • rder.fill((Warehouse) warehouse.proxy());

assertFalse(order.isFilled()); }

defines mock() method mocked() objects are verified automatically when test finishes call mock() to make mocked object

http://martinfowler.com/articles/mocksArentStubs.html

Thursday, October 25, 2012

slide-65
SLIDE 65

jMock 1: setting expectations

public void testOrderIsFilledIfEnoughInWarehouse() { Order order = new Order(TALISKER, 50); Mock warehouseMock = new Mock(Warehouse.class); warehouseMock.expects(once()).method("hasInventory") .with(eq(TALISKER),eq(50)) .will(returnValue(true)); warehouseMock.expects(once()).method("remove") .with(eq(TALISKER), eq(50)) .after("hasInventory");

  • rder.fill((Warehouse) warehouseMock.proxy());

warehouseMock.verify(); assertTrue(order.isFilled()); }

hasInventory(TALISKER, 50) should be called once, and will return true remove(TALISKER, 50) should be called once, after hasInventory() call expectations define the expected usage of mock

  • bject in a specific test

http://martinfowler.com/articles/mocksArentStubs.html

Thursday, October 25, 2012

slide-66
SLIDE 66

EasyMock 1: setting expectations

public class OrderEasyTester extends TestCase { ... private MockControl warehouseControl; private Warehouse warehouseMock; public void setUp() { warehouseControl = MockControl.createControl(Warehouse.class); warehouseMock = (Warehouse) warehouseControl.getMock(); } public void testOrderIsFilledIfEnoughInWarehouse() { Order order = new Order(TALISKER, 50); warehouseMock.hasInventory(TALISKER, 50); warehouseControl.setReturnValue(true); warehouseMock.remove(TALISKER, 50); warehouseControl.replay();

  • rder.fill(warehouseMock);

warehouseControl.verify(); assertTrue(order.isFilled()); }

normal JUnit TestCase record and replay approach to setting expectations compiled method calls

http://martinfowler.com/articles/mocksArentStubs.html

Thursday, October 25, 2012

slide-67
SLIDE 67

jMock 2: generic API

public class OrderTester extends MockObjectTestCase { ... public void testOrderIsFilledIfEnoughInWarehouse() { final Order order = new Order(TALISKER, 50); final Warehouse warehouseMock = mock(Warehouse.class); checking(new Expectations() {{ final Sequence ordering = sequence("ordering");

  • neOf (warehouseMock).hasInventory(TALISKER, 50);

inSequence(ordering);

  • neOf (wareHouseMock).remove(TALISKER, 50);

inSequence(ordering); }}

  • rder.fill(warehouseMock);

assertTrue(order.isFilled()); }

with Java generics, no Mock class, no typecasting expectations stored in separate Expectations object Java Double-Brace initializer block sequences are

  • ptional and

separate objects

EasyMock 3.0 also has a generic API

Thursday, October 25, 2012

slide-68
SLIDE 68

Mock libraries

j/</%*#$5. "E5?FF.(%.2#$<(0:()%$.(%G*34FAi@iFiDFiqFQ/</H%*#$5.H43*+HJ#/4(:3#+%H*345/#$%30F& '6)= "E5?FF:::G#6)=H.33-)3SG*34F*/.(13#$(%F43*+$01G".4- ^c^ 7$45-(>(%.&$0*-62(%&/&43*+$01&K^L? "E5?FF:::G-/%.*#/fG*34F43*+h3)Q(*.%h23*64(0./I30G5"5 X3*+(#=B&6%/)-(&:$."&^c^;0$. "E5?FF)-31G/%.#64J6.6#/G*34FAi@iFiDF43*+(#=HJ#34H43*+H3)Q(*.%H.3H.(%.H%5$(%F ^=."30 X3*+(#&HH&6%(%&#(*3#2F#(5-/=&/55#3/*" "E5?FF-/)$SG3#1F43*+(# Y621(&H&432(-(2&30&QX3*+ "E5?FFJ/#42(<G*34F5#3Q(*.%FJ621(F

Thursday, October 25, 2012