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(% !"#$%&'(#$)*+,-*' ?&!"/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
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
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
Acceptance tests K&6%(#&*/0&/22& /0&$.(4&.3&."(& %"355$01&*/#. Thursday, October 25, 2012
Acceptance tests When I add an item to my K&6%(#&*/0&/22& shopping cart /0&$.(4&.3&."(& Then my shopping cart page contains the item %"355$01&*/#. Thursday, October 25, 2012
Acceptance tests When I add an item to my K&6%(#&*/0&/22& shopping cart /0&$.(4&.3&."(& Then my shopping cart page contains the item %"355$01&*/#. P/$.T&U3&."(=& "/<(&.3&)(& -311(2&$0V Thursday, October 25, 2012
Acceptance tests Given I am logged in K&6%(#&*/0&/22& When I add an item to my shopping cart /0&$.(4&.3&."(& Then my shopping cart page contains the item %"355$01&*/#. Given I am not logged in When I add an item to my shopping cart P/$.T&U3&."(=& Then my shopping cart page "/<(&.3&)(& contains the item -311(2&$0V Thursday, October 25, 2012
Acceptance tests Given I am logged in K&6%(#&*/0&/22& When I add an item to my shopping cart /0&$.(4&.3&."(& Then my shopping cart page contains the item %"355$01&*/#. Given I am not logged in When I add an item to my shopping cart P/$.T&U3&."(=& Then my shopping cart page "/<(&.3&)(& contains the item -311(2&$0V 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 Thursday, October 25, 2012
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
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
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.&)(< Y#/4(:3#+%&J3#&:#$I01&/02ɘ$01&60$.&.(%.%&(S$%.& J3#&/--&432(#0&5#31#/44$01&-/016/1(% U30M.&:#$.(&=36#&3:0&J#/4(:3#+T Thursday, October 25, 2012
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
Integration tests This tests the business logic for an order page public class OrderStateTester extends TestCase { private static String TALISKER = "Talisker"; private Warehouse warehouse = new WarehouseImpl(); making calls to a warehouse protected void setUp() throws Exception { database object warehouse.add(TALISKER, 50); } public void testOrderIsFilledIfEnoughInWarehouse() { order objects and Order order = new Order(TALISKER, 50); warehouse data must order.fill(warehouse); update consistently assertTrue(order.isFilled()); assertEquals(0, warehouse.getInventory(TALISKER)); } public void testOrderNotFilledIfNotEnoughInWarehouse() { Order order = new Order(TALISKER, 51); order.fill(warehouse); assertFalse(order.isFilled()); assertEquals(50, warehouse.getInventory(TALISKER)); } } Thursday, October 25, 2012
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
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
>(%I01&$%& "/#2T Thursday, October 25, 2012
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
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
Testing web pages Thursday, October 25, 2012
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
Browser testing, Part 2 $0%./--&46-I5-(&)#3:%(#% /.&-(/%.&L,B&Y$#(J3SB&7/J/#$B&!"#34( ."(#(&/#(&:/=%&.3<&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
Browser testing, Part 3 Thursday, October 25, 2012
Browser testing, Part 3 ;%(&/&:()&60$.&.(%I01&.33- Thursday, October 25, 2012
Browser testing, Part 3 ;%(&/&:()&60$.&.(%I01&.33- U3(%&03.&0((2&.3&)(&:#$E(0&$0&."(& %/4(&-/016/1(&/%&=36#&%(#<(#T Thursday, October 25, 2012
Recommend
More recommend