SlideShare ist ein Scribd-Unternehmen logo
1 von 142
Unit Testing Software Quality Principles Dr Danny Powell K. J. Ross & Associates Pty. Ltd. Suite 4, Ground Floor 13a Narrabang Way Belrose NSW 2085 Telephone: 02 9450 2333 Facsimile: 02 9450 2744 Mobile: 0404 922 177 Email: dannyp@kjross.com.au http//www.kjross.com.au $ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è?=è?= Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0Rè BW‹ÎètÆD$pèF=ÇD==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿÿ ‹ D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0R èùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËè-C=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=Æ $hØ#PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è ™ êÿÿ‹N4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-ÿÿPL$Æ D$Hè#A=A=’”ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$ è“9=;Öt‹ASW‹°‹<‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøê Æ„$¤’Æ„$¤Æ„èÛ:=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQ h$èƒ?=è?=è?=-Ëè-èC=$‹ÌèÛ:=‰d$0RèùB>=$->=$L$(ÆD$DèÆèÛ:=D$pèF=ÇD¾==è°= =‹|$PËè-èC=$‹Ëè-èC=$‹Ì‰d$0RèùBÿÿ‹N4jèßêÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A= -óÿÿPL$ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è? =è?=-Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0 RèùBW‹ÎètÆD$pèF=ÇD==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿ ÿ‹D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0Rè ùB>=$-=$L$(ÆD$Dè¾==è°==‹|$PËè-èC=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=ÆD$hØ #PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™êÿÿ‹N 4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-PL$ÆD$Hè#A=A=’” ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$è“9=;Öt‹ASW‹°‹< ‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøêÆ„$¤’Æ„$¤Æ„èÛ :=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF= ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$ ‹ ÌèÛ:=‰d$0RèùB>=$->=$L$(ÆD$DèÆèÛ:=D$pèF=ÇD¾==è°==‹|$PËè-èC=$‹Ëè-èC=$‹Ì‰ d$0RèùBÿÿ‹N4jèßêÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-óÿÿPL$ÆD$Hè#A=A=’” ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0R èùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0RèùBW‹ÎètÆD$pèF= D==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿÿ‹D$…À~AD$4L$PT$ QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè ==è°==‹|$PËè-èC=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=ÆD$hØ#PRŒ$ € ÆD$tè4F= ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™êÿÿ‹N4jèßêËè-èC=$‹Ì‰d$ 0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-óÿÿPL$ÆD$Hè#A=A=’”ÃèV@=”Ãè@= èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$è“9=;Öt‹ASW‹°‹<‰‹A‰<° _[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøêÆ„$¤’Æ„$¤Æ„èÛ:=$¤ÆD$pèF=ÇD $ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è?=è?= Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0Rè BW‹ÎètÆD$pèF=ÇD==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿÿ ‹ D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0R èùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËè-C=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=Æ $hØ#PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è ™ êÿÿ‹N4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-ÿÿPL$Æ D$Hè#A=A=’”ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$ è“9=;Öt‹ASW‹°‹<‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøê Æ„$¤’Æ„$¤Æ„èÛ:=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQ h$èƒ?=è?=è?=-Ëè-èC=$‹ÌèÛ:=‰d$0RèùB>=$->=$L$(ÆD$DèÆèÛ:=D$pèF=ÇD¾==è°= =‹|$PËè-èC=$‹Ëè-èC=$‹Ì‰d$0RèùBÿÿ‹N4jèßêÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A= -óÿÿPL$ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è? ‹ D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0Rè ùB>=$-=$L$(ÆD$Dè¾==è°==‹|$PËè-èC=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=ÆD$hØ #PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™êÿÿ‹N 4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-PL$ÆD$Hè#A=A=’” ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$è“9=;Öt‹ASW‹°‹< ‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøêÆ„$¤’Æ„$¤Æ„èÛ :=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF= ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$
Test Driven Development ,[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
White-Box Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
White-Box Testing ,[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Statement, Branch and Path Coverage
Statement Coverage ,[object Object],[object Object]
Branch Coverage ,[object Object],[object Object]
Path Coverage ,[object Object],[object Object]
Test Case ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Statement, Branch and Path Coverage Differences ,[object Object],[object Object],[object Object],[object Object]
Coverage Test Design ,[object Object],[object Object],[object Object],[object Object],[object Object]
Binary Search
Sample Run ,[object Object],[object Object],1 2 3 4 5 6 7 8 9 10 T = Bot Row Top T(Row) = 5 Found = FALSE Key = 6
Sample Run ,[object Object],1 2 3 4 5 6 7 8 9 10 T = Bot L, Mid Top T(Mid) = 5 Found = FALSE Key = 6
Sample Run ,[object Object],1 2 3 4 5 6 7 8 9 10 T = Bot Row Top T(Mid) = 8 Found = FALSE Key = 6 Mid
Sample Run ,[object Object],[object Object],1 2 3 4 5 6 7 8 9 10 T = Bot, Mid, Row Top T(Mid) = 6 Found = TRUE Key = 6 Row = 6
Propose Coverage Paths ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Proposing Test Cases ,[object Object],[object Object],[object Object],[object Object]
Propose Coverage Paths ,[object Object],[object Object],[object Object]
Propose Coverage Paths ,[object Object],[object Object],[object Object],[object Object],[object Object]
Review of Coverage Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Loop Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Basis Path Testing ,[object Object],[object Object],[object Object],[object Object]
Basis Path Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review of Basis Path Testing ,[object Object],[object Object],[object Object]
Beizer’s Loop Tests [Bei95a]  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Branch Condition Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Branch Condition Coverage ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Branch Condition Combination Coverage ,[object Object],[object Object],[object Object]
Modified Condition Decision Coverage ,[object Object],[object Object],[object Object],[object Object]
Modified Condition Decision Coverage ,[object Object]
Modified Condition Decision Coverage ,[object Object],[object Object],[object Object],[object Object]
Condition Coverage Issues ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
White-Box Techniques Conclusions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pros and Cons of White-Box Testing ,[object Object],[object Object],[object Object],[object Object]
Pros and Cons of White-Box Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pros and Cons of White-Box Testing ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],Discussion
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
Unit Test Frameworks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JUnit ,[object Object],[object Object],[object Object],[object Object],[object Object]
Building JUnit Tests ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Case Study - Money Class class Money { private int fAmount; private String fCurrency; public Money(int amount, String currency) {         fAmount= amount; fCurrency= currency; } public int amount() { return fAmount; } public String currency() {   return fCurrency; } public Money add(Money m) { return new Money(amount()+m.amount(), currency()); } }
Case Study - Test Case ,[object Object],public class MoneyTest extends TestCase { //… public void testSimpleAdd() { Money m12CHF= new Money(12, CHF&quot;);   Money m14CHF= new Money(14, &quot;CHF&quot;); Money expected= new Money(26, &quot;CHF&quot;); Money result=m12CHF.add(m14CHF);  assert(expected.equals(result)); } } Object Creation Method Under Test Result Verification assert - check boolean result is true Junit Test Case
Case Study - Test Case ,[object Object],public void testEquals() { Money m12CHF= new Money(12, &quot;CHF&quot;); Money m14CHF= new Money(14, &quot;CHF&quot;); assert(!m12CHF.equals(null));  assertEquals(m12CHF, m12CHF);  assertEquals(m12CHF, new Money(12, &quot;CHF&quot;));  assert(!m12CHF.equals(m14CHF)); } Result Verification assertEquals - compare two values
Case Study - Optimised Test Cases ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Case Study - Test Suite ,[object Object],[object Object],[object Object],[object Object]
Case Study - Running Tests ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JUnit ,[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],Demonstration
Ant ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code Coverage ,[object Object],[object Object],[object Object]
Code Coverage ,[object Object],[object Object]
Cruise Control http://cruisecontrol.sourceforge.net/ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
eLVAS Cruise Control
eLVAS Cruise Control
eLVAS Cruise Control
Unit Test Organisation ,[object Object],[object Object],[object Object]
Unit Test Principles ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Other Frameworks http://c2.com/cgi/wiki?TestingFramework ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP Unit ,[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP Unit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse( &quot;http://www.meterware.com/testpage.html&quot; );
HTTP Unit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP Unit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],request = form.getRequest(); request.setParameter( &quot;Food&quot;, &quot;Italian&quot; ); request.removeParameter( &quot;CreditCard&quot; ); response = wc.getResponse( request );
HTTP Unit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],String[][] colors = resp.getTables()[1].asText(); assertEquals( &quot;Name&quot;, colors[0][0] ); assertEquals( &quot;Color&quot;, colors[0][1] ); assertEquals( &quot;gules&quot;, colors[1][0] ); assertEquals( &quot;red&quot;, colors[1][1] ); assertEquals( &quot;sable&quot;, colors[2][0] ); assertEquals( &quot;black&quot;, colors[2][1] );  name color gules red sable black
HTML Unit ,[object Object],[object Object],[object Object]
SQLUnit http://sqlunit.sourceforge.net ,[object Object],[object Object],[object Object],[object Object],[object Object]
SQLUnit GUI Tool ,[object Object],<test name=&quot;Checking returned value from customer&quot;> <sql> <stmt>select custId from customer where custId=?</stmt>   <param id=&quot;1&quot; type=&quot;INTEGER&quot; inout=&quot;in&quot; is-null=&quot;false&quot;> 1</param> </sql> <result><resultset id=&quot;1&quot;> <row id=&quot;1&quot;><col id=&quot;1&quot; type=&quot;INTEGER&quot;>1</col></row> </resultset></result>  </test>
SQLUnit Output Buildfile: build.xml init: test-ant-task: [sqlunit] Getting connection...  [sqlunit] Setting up test...  [sqlunit] Running test[1]: Adding department HR  [sqlunit] Running test[2]: Adding department InfoTech using non-Callable form  [sqlunit] Running test[3]: Adding Employee John Doe to InfoTech  [sqlunit] Running test[4]: Adding John Doe again  [sqlunit] Running test[5]: Adding Jane Doe to HR  [sqlunit] Running test[6]: Adding Dick Tracy to InfoTech  [sqlunit] Running test[7]: Updating Hourly Rate for John  [sqlunit] Running test[8]: Looking up John Doe by name  [sqlunit] Running test[9]: Looking up all employees in InfoTech  [sqlunit] Running test[10]: Adding timecard for John  [sqlunit] Running test[11]: Adding another timecard for John  [sqlunit] Running test[12]: Adding timecard for Dick
[sqlunit] Running test[13]: Getting monthly report for InfoTech  [sqlunit] No match on variable at [rset,row,col]=([1,1,4]  [sqlunit] *** expected:  [sqlunit] <result>  [sqlunit] <resultset id=&quot;1&quot;>  [sqlunit] <row id=&quot;1&quot;>  [sqlunit] <col id=&quot;1&quot; type=&quot;VARCHAR&quot;>Information Technology</col>  [sqlunit] <col id=&quot;2&quot; type=&quot;VARCHAR&quot;>John Doe</col>  [sqlunit] <col id=&quot;3&quot; type=&quot;INTEGER&quot;>16</col>  [sqlunit] <col id=&quot;4&quot; type=&quot;NUMERIC&quot;>56.00</col>  [sqlunit] <col id=&quot;5&quot; type=&quot;NUMERIC&quot;>880.00</col>   [sqlunit] </row>  [sqlunit] <row id=&quot;2&quot;>   [sqlunit] </row>  sqlunit] </resultset>  [sqlunit] </result>  [sqlunit] *** but got:  [sqlunit] <result>  [sqlunit] <resultset id=&quot;1&quot;>  [sqlunit] <row id=&quot;1&quot;>  [sqlunit] <col id=&quot;1&quot; type=&quot;VARCHAR&quot;>Information Technology</col>  [sqlunit] <col id=&quot;2&quot; type=&quot;VARCHAR&quot;>John Doe</col>  [sqlunit] <col id=&quot;3&quot; type=&quot;INTEGER&quot;>16</col>  [sqlunit] <col id=&quot;4&quot; type=&quot;NUMERIC&quot;>55.00</col> [sqlunit] <col id=&quot;5&quot; type=&quot;NUMERIC&quot;>880.00</col>   [sqlunit] </row>   [sqlunit] </resultset>  [sqlunit] </result>  [sqlunit] Tearing down test...  [sqlunit] Time: 1.204   [sqlunit] OK (1 tests)  [sqlunit] BUILD SUCCESSFUL Total time: 2 seconds
DBUnit http://dbunit.sourceforge.net ,[object Object],[object Object],[object Object]
DBUnit ,[object Object],<EMPLOYEE employee_uid='1‘ start_date='2001-01-01‘ first_name='Andrew‘ ssn=‘000-29-2030‘ last_name='Glover‘ />
Nunit ,[object Object],[object Object]
Nunit Example StackTest.cs ,[object Object],[object Object],using System; using NUnit.Framework; [TestFixture] public class StackFixture { private Stack stack; [SetUp] public void Init() { stack = new Stack(); } [Test] public void Empty() { Assert.IsTrue(stack.IsEmpty); } [Test] public void PushOne() { stack.Push(“first element”); Assert.IsFalse(stack.IsEmpty, “ After Push, IsEmpty should  be false”); } [Test] public void Pop() { stack.Push(“first element”); stack.Pop(); Assert.IsTrue(stack.IsEmpty, “ After Push - Pop, IsEmpty  should be true”); } … …
Nunit Example Stack.cs using System; using System.Collections; public class Stack { private ArrayList elements = new ArrayList(); public bool IsEmpty { get {   return (elements.Count ==  0); } } public void Push(object element) { elements.Insert(0, element); } public object Pop() { object top = Top(); elements.RemoveAt(0); return top; } public object Top() { if(IsEmpty)   throw new    InvalidOperationException( “Stack is Empty”); return elements[0]; } }
[object Object],[object Object],[object Object],[object Object],Discussion
[object Object],[object Object],Discussion
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
Tools to Aid in Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Testing with a Debugger ,[object Object],[object Object],[object Object],[object Object]
Testing with a Debugger ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Types of Test Coverage ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test Coverage ,[object Object],[object Object],[object Object],[object Object]
Test Coverage ,[object Object],[object Object],[object Object]
Test Coverage - Case Study ,[object Object],Source :  Handbook of software reliability engineering,  Horgan, 1996
Getting High Test Coverage ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test Coverage - a Final Note ,[object Object],[object Object],[object Object],[object Object],[object Object]
Code Coverage Tools ,[object Object],[object Object],[object Object],[object Object]
http://c2.com/cgi/wiki?CodeCoverageTools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test Coverage ,[object Object],[object Object],[object Object]
Test Coverage
Test Coverage Tools
Memory Bugs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Memory Leak Detection ,[object Object],[object Object],[object Object]
Memory Leak Detection ,[object Object],[object Object],[object Object]
Purify ,[object Object]
Performance Bugs ,[object Object],[object Object],[object Object],[object Object],[object Object]
Performance Measurement ,[object Object],[object Object],[object Object],[object Object],[object Object]
Quest JProbe ,[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Module (Unit) Testing ,[object Object],[object Object],[object Object],[object Object]
Module Testing Questions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
White Box Module Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Module Test Technique ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Module Test Approaches ,[object Object],[object Object],[object Object],[object Object]
Adhoc Approach ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Checklist Approach ,[object Object],[object Object],[object Object]
Checklist Approach ,[object Object],[object Object],[object Object],[object Object]
Example Test Checklists Module Specific ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example Test Checklists Generic 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example Test Checklists Generic 2   General 1 Does input data vary, including maximum, minimum, and nominal values?  (All alike data, especially all zeroes, is usually a poor choice.) 2 Is erroneous input data used?  (All error conditions should be checked.) 3 Do the tests demonstrate that the code completely satisfies each requirement? 4 Does the actual output match the expected output?   Data-Declaration Error Testing 5 Have all the data structures been explicitly tested? 6 Has all data been properly initialized? (e.g., initialized with the correct data type, default values) 7 Have all global data structures been tested?   Data Referencing Errors 8 Are all variables set to the proper value or initialized correctly?
Automated Approach ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Planned Approach ,[object Object],[object Object],[object Object]
Planned Approach ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Planned Approach ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview ,[object Object],[object Object],[object Object],[object Object]
Test Harnesses ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test Automation Techniques ,[object Object],[object Object],[object Object],[object Object],[object Object]
Test Automation Techniques ,[object Object],[object Object],[object Object],[object Object]
Data Driven Test Harness The test harness usually conforms to the following structure: while data file is not empty read inputs and outputs from data file call function with inputs if results of function match expected outputs register TC passed else register TC failed end if end while output summary
Example - Harness /* Calculate the hypotenuse of a right angle */ /* triangle .  nOpposite and nAdjacent must values */ /* be non negative .  Return the hypotenuse or –1 */ /* for invalid input */ double calcHypotenuse ( double nOpposite, double nAdjacent ) { if ( nOpposite < 0 or nAdjacent < 0 ) { return –1; } return ( sqrt(pow(nOpposite,2)+ pow(nAdjacent,2)) ); }   /* Test Harness – this does all the work */ main(…) { int count = 0; // count the no of tests executed int fail = 0; double result; … /* open the input script */ … while ( line = readLine(inputFile) != EOF ) { if ( is_comment(line) ) { continue; } count++; /* split line into testid,opposite,adjacent,expected */ … result = calcHypotenuse ( opposite, adjacent ); if ( result != expected ) { fail++; output(“Test failed: %s( %d, %d ) got %d expected %d”, testid, opposite, adjacent, result, expected ); } }   /* output the final stats */ output(“Tests run: %d”, count); output(“Tests OK: %d”, count-fail); output(“Tests failed: %d”, fail); }
Example - Harness Run ,[object Object],[object Object],# format: testid,opposite,adjacent,expected Test1,3,4,5 Test2,3,4,6 # just to try and force a failure Test3,-3,4,-1 Test4,4,-1,-1 Test5,0,4,4 Test failed: Test2( 3, 4 ) got 5 expected 6  Tests run: 5 Tests OK: 4 Tests failed: 1
Test Stubs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test Stubs ,[object Object],[object Object]
Example - Stub ,[object Object],enum Method { GET, POST }; struct response { int code; String content; String header; }; /* static stub – commonly used since predictable results */ response sendHttpRequest( String url, Method getpost, String params) { response res; res.code = 200; /* status OK */ res.content = “<html><title>Hello</title><body>testing</body></html>”; res.header = “”; return res; }
Example - Stub ,[object Object],/* get value from global lookup table – generated from input script */ response sendHttpRequest( String url, Method getpost, String params) { response res; /* assume test input script included data to populate lookup table */ res = lookup(url); return res; }
Example - Stub ,[object Object],/* get value from a file */ response sendHttpRequest( String url, Method getpost, String params) { response res; /* assume a file has been opened and filehandle is accessible */ if ( code = readLine(filehandle) ) { res.code = code; } else { res.code = 400; /* fail */ } if ( content = readLine(filehandle) ) { res.content = content; } if ( header = readLine(filehandle) ) { res.header = header; } return res; }
Example - Stub ,[object Object],[object Object],/* get value from a file */ response sendHttpRequest( String url, Method getpost, String params) { response res; /* assume a file has been opened and filehandle is accessible */ if ( mode = normal ) { res = actual_sendHttpRequest(url, getpost, params) } else { res.code = 400; /* fail */ } return res; }
Coordinating Harnesses and Stubs TC01:3,4,1998; 30 ;T # normal date TC02:29,2,1999; 28 ;F # not a leap year TC03:29,2,2000; 29 ;T # leap year TC04:29,2,2100; 28 ;F # not a leap year The data file may have fields indicating data that should be returned by stubbed functions during the test. The stubbed functions return global variables that are set by the test harness after reading the appropriate value from the test file. For example, the  daysInMonth  function used by  checkDate  is stubbed.  It returns a pre-determined value from the test harness data file (shown in  bold ). bool checkDate(int d, int m, int y) {   if ( y <= 0 ) return false;   if ( m < 1 || m > 12 ) return false;   if ( d < 1 || d > daysInMonth(m, isLeapYear(y)) )   return false;   return true; }
Coordinating Harnesses and Stubs (cont) TC01:3,4,1998; 30 ;T # normal date TC02:29,2,1999; 28 ;F # not a leap year TC03:29,2,2000; 29 ;T # leap year TC04:29,2,2100; 28 ;F # not a leap year int daysInMonth (int month, bool leapYear) { return  globalDaysInMonth ; } int isLeapYear(int y) { return true; } /* simple stub */   while (data remaining in file) {   read data line into (TCID, (d, m, y),  globalDaysInMonth , Expected)   if (checkDate(d,m,y) == Expected) {   register (TCID,pass)   else   register (TCID,fail) } bool checkDate(int d, int m, int y) {   if ( y <= 0 ) return false;   if ( m < 1 || m > 12 ) return false;   if ( d < 1 || d > daysInMonth(m, isLeapYear(y)) )   return false;   return true; }
Mock Objects ,[object Object],[object Object]
Mock Object Example From Test Driven Development, A Practical Guide , David Astels, Prentice Hall, 2003 ,[object Object],[object Object],[object Object],public class Player {   Die myD20 = null; public Player(Die d20) {   myD20 = d20;   } public boolean attack(Orc anOrc) {   if (myD20.roll() > = 13) {   return hit(anOrc);   } else {   return miss();   }   } private boolean hit(Orc anOrc) {   anOrc.injure(myD20.roll());   return true;   } private boolean miss() {   return false;   } }
Create Mock Interface ,[object Object],public interface Rollable {   int roll() } public class Die implements Rollable {   // … } public class Player {   Rollable  myD20 = null; public Player( Rollable  d20) {   myD20 = d20;   } //… }
Create Tests With Mock ,[object Object],[object Object],[object Object],[object Object],public class MockDie implements Rollable {   private int returnValue; public MockDie(int constantReturnValue) {   returnValue = constantReturnValue;   } public int roll() {   return returnValue;   } } public void testMiss() {   Rollable d20 = new MockDie(10);   Player badFighter = new Player(d20);   Orc anOrc = new Orc();   assertFalse(“Attack should have missed.”,  badFighter.attack(anOrc)); }
Uses of Mock Objects (and stubs in general) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Test Driven Development, A Practical Guide , David Astels, Prentice Hall, 2003

Weitere ähnliche Inhalte

Ähnlich wie Testing

Quality Assurance
Quality AssuranceQuality Assurance
Quality AssuranceKiran Kumar
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesKhuong Nguyen
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchartJordan Delacruz
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhPankaj Thakur
 
CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4SIMONTHOMAS S
 
ISTQB, ISEB Lecture Notes- 4
ISTQB, ISEB Lecture Notes- 4ISTQB, ISEB Lecture Notes- 4
ISTQB, ISEB Lecture Notes- 4onsoftwaretest
 
Introductiontoflowchart 110630082600-phpapp01
Introductiontoflowchart 110630082600-phpapp01Introductiontoflowchart 110630082600-phpapp01
Introductiontoflowchart 110630082600-phpapp01VincentAcapen1
 
A study on the efficiency of a test analysis method utilizing test-categories...
A study on the efficiency of a test analysis method utilizing test-categories...A study on the efficiency of a test analysis method utilizing test-categories...
A study on the efficiency of a test analysis method utilizing test-categories...Tsuyoshi Yumoto
 
Test Optimization With Design of Experiment
Test Optimization With Design of ExperimentTest Optimization With Design of Experiment
Test Optimization With Design of Experimentajitbkulkarni
 
Test Case Design Techniques
Test Case Design TechniquesTest Case Design Techniques
Test Case Design TechniquesMurageppa-QA
 
Test Case Design
Test Case DesignTest Case Design
Test Case DesignVidya-QA
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and TechniqueFayis-QA
 
Test Case Design & Technique
Test Case Design & TechniqueTest Case Design & Technique
Test Case Design & TechniqueRajesh-QA
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and TechniqueSachin-QA
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and TechniqueANKUR-BA
 
1414_lecturueueueueuueueeueueueuusuee_7.ppt
1414_lecturueueueueuueueeueueueuusuee_7.ppt1414_lecturueueueueuueueeueueueuusuee_7.ppt
1414_lecturueueueueuueueeueueueuusuee_7.pptabdulbasetalselwi
 

Ähnlich wie Testing (20)

Quality Assurance
Quality AssuranceQuality Assurance
Quality Assurance
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniques
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchart
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4
 
ISTQB, ISEB Lecture Notes- 4
ISTQB, ISEB Lecture Notes- 4ISTQB, ISEB Lecture Notes- 4
ISTQB, ISEB Lecture Notes- 4
 
Introductiontoflowchart 110630082600-phpapp01
Introductiontoflowchart 110630082600-phpapp01Introductiontoflowchart 110630082600-phpapp01
Introductiontoflowchart 110630082600-phpapp01
 
Whitebox
WhiteboxWhitebox
Whitebox
 
A study on the efficiency of a test analysis method utilizing test-categories...
A study on the efficiency of a test analysis method utilizing test-categories...A study on the efficiency of a test analysis method utilizing test-categories...
A study on the efficiency of a test analysis method utilizing test-categories...
 
Test Optimization With Design of Experiment
Test Optimization With Design of ExperimentTest Optimization With Design of Experiment
Test Optimization With Design of Experiment
 
Test Case Design Techniques
Test Case Design TechniquesTest Case Design Techniques
Test Case Design Techniques
 
White box testing
White box testingWhite box testing
White box testing
 
Test Case Design
Test Case DesignTest Case Design
Test Case Design
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and Technique
 
Test Case Design & Technique
Test Case Design & TechniqueTest Case Design & Technique
Test Case Design & Technique
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and Technique
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and Technique
 
Testing
TestingTesting
Testing
 
1414_lecturueueueueuueueeueueueuusuee_7.ppt
1414_lecturueueueueuueueeueueueuusuee_7.ppt1414_lecturueueueueuueueeueueueuusuee_7.ppt
1414_lecturueueueueuueueeueueueuusuee_7.ppt
 
Catapult DOE Case Study
Catapult DOE Case StudyCatapult DOE Case Study
Catapult DOE Case Study
 

Mehr von nazeer pasha

Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)nazeer pasha
 
Testing Types Presentation
Testing Types PresentationTesting Types Presentation
Testing Types Presentationnazeer pasha
 
Doe Taguchi Basic Manual1
Doe Taguchi Basic Manual1Doe Taguchi Basic Manual1
Doe Taguchi Basic Manual1nazeer pasha
 
Teaching Testing Qw%202001
Teaching Testing Qw%202001Teaching Testing Qw%202001
Teaching Testing Qw%202001nazeer pasha
 
Software Testing Guide
Software Testing GuideSoftware Testing Guide
Software Testing Guidenazeer pasha
 
Cstp Certification Compare
Cstp Certification CompareCstp Certification Compare
Cstp Certification Comparenazeer pasha
 
Exploratory Testing
Exploratory TestingExploratory Testing
Exploratory Testingnazeer pasha
 
Testing Types And Models
Testing Types And ModelsTesting Types And Models
Testing Types And Modelsnazeer pasha
 
Swe3643 2006 Decision Table Based Testing
Swe3643 2006 Decision Table Based TestingSwe3643 2006 Decision Table Based Testing
Swe3643 2006 Decision Table Based Testingnazeer pasha
 

Mehr von nazeer pasha (20)

Linux
LinuxLinux
Linux
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)
 
Test Techniques
Test TechniquesTest Techniques
Test Techniques
 
Testing Types Presentation
Testing Types PresentationTesting Types Presentation
Testing Types Presentation
 
Good Ppt On Risk
Good Ppt On RiskGood Ppt On Risk
Good Ppt On Risk
 
Bug Advocacy
Bug AdvocacyBug Advocacy
Bug Advocacy
 
Doe Taguchi Basic Manual1
Doe Taguchi Basic Manual1Doe Taguchi Basic Manual1
Doe Taguchi Basic Manual1
 
Teaching Testing Qw%202001
Teaching Testing Qw%202001Teaching Testing Qw%202001
Teaching Testing Qw%202001
 
Orth Arrays
Orth ArraysOrth Arrays
Orth Arrays
 
Testing
TestingTesting
Testing
 
Tc Checklist
Tc ChecklistTc Checklist
Tc Checklist
 
Software Testing Guide
Software Testing GuideSoftware Testing Guide
Software Testing Guide
 
Cstp Certification Compare
Cstp Certification CompareCstp Certification Compare
Cstp Certification Compare
 
Exploratory Testing
Exploratory TestingExploratory Testing
Exploratory Testing
 
Chanakya Niti
Chanakya NitiChanakya Niti
Chanakya Niti
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Testing Types And Models
Testing Types And ModelsTesting Types And Models
Testing Types And Models
 
Swtesting
SwtestingSwtesting
Swtesting
 
Testing Framework
Testing FrameworkTesting Framework
Testing Framework
 
Swe3643 2006 Decision Table Based Testing
Swe3643 2006 Decision Table Based TestingSwe3643 2006 Decision Table Based Testing
Swe3643 2006 Decision Table Based Testing
 

Kürzlich hochgeladen

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Kürzlich hochgeladen (20)

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

Testing

  • 1. Unit Testing Software Quality Principles Dr Danny Powell K. J. Ross & Associates Pty. Ltd. Suite 4, Ground Floor 13a Narrabang Way Belrose NSW 2085 Telephone: 02 9450 2333 Facsimile: 02 9450 2744 Mobile: 0404 922 177 Email: dannyp@kjross.com.au http//www.kjross.com.au $ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è?=è?= Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0Rè BW‹ÎètÆD$pèF=ÇD==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿÿ ‹ D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0R èùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËè-C=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=Æ $hØ#PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è ™ êÿÿ‹N4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-ÿÿPL$Æ D$Hè#A=A=’”ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$ è“9=;Öt‹ASW‹°‹<‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøê Æ„$¤’Æ„$¤Æ„èÛ:=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQ h$èƒ?=è?=è?=-Ëè-èC=$‹ÌèÛ:=‰d$0RèùB>=$->=$L$(ÆD$DèÆèÛ:=D$pèF=ÇD¾==è°= =‹|$PËè-èC=$‹Ëè-èC=$‹Ì‰d$0RèùBÿÿ‹N4jèßêÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A= -óÿÿPL$ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è? =è?=-Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0 RèùBW‹ÎètÆD$pèF=ÇD==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿ ÿ‹D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0Rè ùB>=$-=$L$(ÆD$Dè¾==è°==‹|$PËè-èC=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=ÆD$hØ #PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™êÿÿ‹N 4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-PL$ÆD$Hè#A=A=’” ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$è“9=;Öt‹ASW‹°‹< ‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøêÆ„$¤’Æ„$¤Æ„èÛ :=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF= ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$ ‹ ÌèÛ:=‰d$0RèùB>=$->=$L$(ÆD$DèÆèÛ:=D$pèF=ÇD¾==è°==‹|$PËè-èC=$‹Ëè-èC=$‹Ì‰ d$0RèùBÿÿ‹N4jèßêÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-óÿÿPL$ÆD$Hè#A=A=’” ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0R èùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0RèùBW‹ÎètÆD$pèF= D==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿÿ‹D$…À~AD$4L$PT$ QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè ==è°==‹|$PËè-èC=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=ÆD$hØ#PRŒ$ € ÆD$tè4F= ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™êÿÿ‹N4jèßêËè-èC=$‹Ì‰d$ 0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-óÿÿPL$ÆD$Hè#A=A=’”ÃèV@=”Ãè@= èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$è“9=;Öt‹ASW‹°‹<‰‹A‰<° _[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøêÆ„$¤’Æ„$¤Æ„èÛ:=$¤ÆD$pèF=ÇD $ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è?=è?= Ëè-èC=$‹Ì‰d$0RèùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËèÆD$pèF=ÇD-èC=$‹Ì‰d$0Rè BW‹ÎètÆD$pèF=ÇD==ÿèƒÇÿÿÿÿ‹t$j‹Îèc<=PT$QD$ RPL$@èTþÿÿL$èÛ:=QRL$4è¸ýÿÿ ‹ D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0R èùB>=$->=$L$(ÆD$Dè¾==è°==‹|$PËè-C=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=Æ $hØ#PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è ™ êÿÿ‹N4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-ÿÿPL$Æ D$Hè#A=A=’”ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$ è“9=;Öt‹ASW‹°‹<‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøê Æ„$¤’Æ„$¤Æ„èÛ:=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQ h$èƒ?=è?=è?=-Ëè-èC=$‹ÌèÛ:=‰d$0RèùB>=$->=$L$(ÆD$DèÆèÛ:=D$pèF=ÇD¾==è°= =‹|$PËè-èC=$‹Ëè-èC=$‹Ì‰d$0RèùBÿÿ‹N4jèßêÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A= -óÿÿPL$ÆD$Hè#A=A=’”ÃèV@=”Ãè@=èä?=RPˆD$pèF=ÇD$Pè[|,L$LT$PQh$èƒ?=è? ‹ D$…À~AD$4L$PT$QDèÛ:=$ RPL$@è“[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$‹Ì‰d$0Rè ùB>=$-=$L$(ÆD$Dè¾==è°==‹|$PËè-èC=$‹þÿÿL$èš:=QRL$4è̉dèÛ:=$,Pè Ž G=ÆD$hØ #PRŒ$ € ÆD$tè4F=ÆD$pèF=ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™êÿÿ‹N 4jèßêËè-èC=$‹Ì‰d$0RèùBÿÿ…Àu8hV‹Ëè-èC=$‹Ì‰d$0RèùB=B=‘A=-PL$ÆD$Hè#A=A=’” ÃèV@=”Ãè@=èä·ýÿÿ‹D$…À¿èÛ:=¸$”ÆD$pèF=ÇD:=$j/L$0è:=L$,ˆ$è“9=;Öt‹ASW‹°‹< ‰‹A‰<°_[^Âó«‹„$4_^3À[ÄÇD$RSÿìêÁéó¥‹Èƒáó¤¾ìêøêÆ„$¤’Æ„$¤Æ„èÛ :=$¤ÆD$pèF=ÇD‹Ì‰dÆD$pèF=ÇD$,Pè Ž G=ÆD$hØ#PèÛ:=RŒ$ € ÆD$tè4F=ÆD$pèF= ÇD$(DjRÿüñ‚‹Èèäçÿÿë3À‹L$H‹QR‹ÈÆD$@‰F4è™ê[|,L$LT$PQh$èƒ?=è?=è?=-Ëè-èC=$
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Statement, Branch and Path Coverage
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49. Case Study - Money Class class Money { private int fAmount; private String fCurrency; public Money(int amount, String currency) {         fAmount= amount; fCurrency= currency; } public int amount() { return fAmount; } public String currency() { return fCurrency; } public Money add(Money m) { return new Money(amount()+m.amount(), currency()); } }
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75. SQLUnit Output Buildfile: build.xml init: test-ant-task: [sqlunit] Getting connection... [sqlunit] Setting up test... [sqlunit] Running test[1]: Adding department HR [sqlunit] Running test[2]: Adding department InfoTech using non-Callable form [sqlunit] Running test[3]: Adding Employee John Doe to InfoTech [sqlunit] Running test[4]: Adding John Doe again [sqlunit] Running test[5]: Adding Jane Doe to HR [sqlunit] Running test[6]: Adding Dick Tracy to InfoTech [sqlunit] Running test[7]: Updating Hourly Rate for John [sqlunit] Running test[8]: Looking up John Doe by name [sqlunit] Running test[9]: Looking up all employees in InfoTech [sqlunit] Running test[10]: Adding timecard for John [sqlunit] Running test[11]: Adding another timecard for John [sqlunit] Running test[12]: Adding timecard for Dick
  • 76. [sqlunit] Running test[13]: Getting monthly report for InfoTech [sqlunit] No match on variable at [rset,row,col]=([1,1,4] [sqlunit] *** expected: [sqlunit] <result> [sqlunit] <resultset id=&quot;1&quot;> [sqlunit] <row id=&quot;1&quot;> [sqlunit] <col id=&quot;1&quot; type=&quot;VARCHAR&quot;>Information Technology</col> [sqlunit] <col id=&quot;2&quot; type=&quot;VARCHAR&quot;>John Doe</col> [sqlunit] <col id=&quot;3&quot; type=&quot;INTEGER&quot;>16</col> [sqlunit] <col id=&quot;4&quot; type=&quot;NUMERIC&quot;>56.00</col> [sqlunit] <col id=&quot;5&quot; type=&quot;NUMERIC&quot;>880.00</col> [sqlunit] </row> [sqlunit] <row id=&quot;2&quot;> [sqlunit] </row> sqlunit] </resultset> [sqlunit] </result> [sqlunit] *** but got: [sqlunit] <result> [sqlunit] <resultset id=&quot;1&quot;> [sqlunit] <row id=&quot;1&quot;> [sqlunit] <col id=&quot;1&quot; type=&quot;VARCHAR&quot;>Information Technology</col> [sqlunit] <col id=&quot;2&quot; type=&quot;VARCHAR&quot;>John Doe</col> [sqlunit] <col id=&quot;3&quot; type=&quot;INTEGER&quot;>16</col> [sqlunit] <col id=&quot;4&quot; type=&quot;NUMERIC&quot;>55.00</col> [sqlunit] <col id=&quot;5&quot; type=&quot;NUMERIC&quot;>880.00</col> [sqlunit] </row> [sqlunit] </resultset> [sqlunit] </result> [sqlunit] Tearing down test... [sqlunit] Time: 1.204 [sqlunit] OK (1 tests) [sqlunit] BUILD SUCCESSFUL Total time: 2 seconds
  • 77.
  • 78.
  • 79.
  • 80.
  • 81. Nunit Example Stack.cs using System; using System.Collections; public class Stack { private ArrayList elements = new ArrayList(); public bool IsEmpty { get { return (elements.Count == 0); } } public void Push(object element) { elements.Insert(0, element); } public object Pop() { object top = Top(); elements.RemoveAt(0); return top; } public object Top() { if(IsEmpty) throw new InvalidOperationException( “Stack is Empty”); return elements[0]; } }
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118. Example Test Checklists Generic 2   General 1 Does input data vary, including maximum, minimum, and nominal values? (All alike data, especially all zeroes, is usually a poor choice.) 2 Is erroneous input data used? (All error conditions should be checked.) 3 Do the tests demonstrate that the code completely satisfies each requirement? 4 Does the actual output match the expected output?   Data-Declaration Error Testing 5 Have all the data structures been explicitly tested? 6 Has all data been properly initialized? (e.g., initialized with the correct data type, default values) 7 Have all global data structures been tested?   Data Referencing Errors 8 Are all variables set to the proper value or initialized correctly?
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127. Data Driven Test Harness The test harness usually conforms to the following structure: while data file is not empty read inputs and outputs from data file call function with inputs if results of function match expected outputs register TC passed else register TC failed end if end while output summary
  • 128. Example - Harness /* Calculate the hypotenuse of a right angle */ /* triangle . nOpposite and nAdjacent must values */ /* be non negative . Return the hypotenuse or –1 */ /* for invalid input */ double calcHypotenuse ( double nOpposite, double nAdjacent ) { if ( nOpposite < 0 or nAdjacent < 0 ) { return –1; } return ( sqrt(pow(nOpposite,2)+ pow(nAdjacent,2)) ); }   /* Test Harness – this does all the work */ main(…) { int count = 0; // count the no of tests executed int fail = 0; double result; … /* open the input script */ … while ( line = readLine(inputFile) != EOF ) { if ( is_comment(line) ) { continue; } count++; /* split line into testid,opposite,adjacent,expected */ … result = calcHypotenuse ( opposite, adjacent ); if ( result != expected ) { fail++; output(“Test failed: %s( %d, %d ) got %d expected %d”, testid, opposite, adjacent, result, expected ); } }   /* output the final stats */ output(“Tests run: %d”, count); output(“Tests OK: %d”, count-fail); output(“Tests failed: %d”, fail); }
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136. Coordinating Harnesses and Stubs TC01:3,4,1998; 30 ;T # normal date TC02:29,2,1999; 28 ;F # not a leap year TC03:29,2,2000; 29 ;T # leap year TC04:29,2,2100; 28 ;F # not a leap year The data file may have fields indicating data that should be returned by stubbed functions during the test. The stubbed functions return global variables that are set by the test harness after reading the appropriate value from the test file. For example, the daysInMonth function used by checkDate is stubbed. It returns a pre-determined value from the test harness data file (shown in bold ). bool checkDate(int d, int m, int y) { if ( y <= 0 ) return false; if ( m < 1 || m > 12 ) return false; if ( d < 1 || d > daysInMonth(m, isLeapYear(y)) ) return false; return true; }
  • 137. Coordinating Harnesses and Stubs (cont) TC01:3,4,1998; 30 ;T # normal date TC02:29,2,1999; 28 ;F # not a leap year TC03:29,2,2000; 29 ;T # leap year TC04:29,2,2100; 28 ;F # not a leap year int daysInMonth (int month, bool leapYear) { return globalDaysInMonth ; } int isLeapYear(int y) { return true; } /* simple stub */ while (data remaining in file) { read data line into (TCID, (d, m, y), globalDaysInMonth , Expected) if (checkDate(d,m,y) == Expected) { register (TCID,pass) else register (TCID,fail) } bool checkDate(int d, int m, int y) { if ( y <= 0 ) return false; if ( m < 1 || m > 12 ) return false; if ( d < 1 || d > daysInMonth(m, isLeapYear(y)) ) return false; return true; }
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.