{"id":279,"date":"2018-07-25T06:05:41","date_gmt":"2018-07-25T06:05:41","guid":{"rendered":"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=279"},"modified":"2018-08-08T05:52:00","modified_gmt":"2018-08-08T05:52:00","slug":"white-box-testing-ii","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/chapter\/white-box-testing-ii\/","title":{"rendered":"White Box Testing II"},"content":{"raw":"<div>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>WHITE BOX TESTING<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">White box is a testing methodology to test the internal structures and working of software. White box testing also know as structural testing is testing based on analysis of internal logic (design, code, etc.).<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>LEARNING OBJECTIVES\u00a0<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 To focus on Program structures, Program internal logic and data structures, Program internal behaviors and states.<\/p>\r\n<p style=\"text-align: justify\">\u2022 To focus on internal program structure and discover all internal program errors.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Example Paths\u00a0<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The following example shows the flow graph and the paths through the nodes, the example shows that the paths P3 and P4 are the same but they have different start and endpoints.<\/p>\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\"><img class=\"aligncenter wp-image-290\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths.png\" alt=\"\" width=\"749\" height=\"291\" \/><\/p>\r\n\r\n<div style=\"text-align: justify\">\r\n\r\n&nbsp;\r\n\r\nIn the example, the paths that form cycles are identified, where P4, P8, P9 does not form\u00a0<span style=\"text-align: initial;font-size: 1em\">cycles<\/span><strong style=\"text-align: initial;font-size: 1em\">.<\/strong>\r\n\r\n<\/div>\r\n<div style=\"text-align: justify\">\r\n\r\n<img class=\"aligncenter wp-image-289\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1.png\" alt=\"\" width=\"732\" height=\"318\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong>MODIFIED CYCLOMATIC COMPLEXITY MEASURES\u00a0<\/strong>\r\n\r\n&nbsp;\r\n\r\nGiven <em>p <\/em>connected components of a graph:\r\n<table style=\"height: 70px\" width=\"382\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 26.0625px\">\u25e6<\/td>\r\n<td style=\"width: 290.063px\">V(G) = e \u2013 n + 2p<\/td>\r\n<td style=\"width: 50.0625px\">(1)<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 26.0625px\">\u25e6<\/td>\r\n<td style=\"width: 290.063px\">VLI(G) = e \u2013 n + p + 1<\/td>\r\n<td style=\"width: 50.0625px\">(2)<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Eq. (2) is known as <em>linearly-independent <\/em>cyclomatic complexity. VLI does not change when program is modularized into <em>p <\/em>modules. A number of industry studies have indicated that the higher V(G), the higher the probability or errors.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"aligncenter size-full wp-image-288\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range.png\" alt=\"\" width=\"403\" height=\"228\" \/>\r\n\r\n<\/div>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">The following example shows computation of the cyclomatic complexity measures where modularization \u00a0does \u00a0not \u00a0increase \u00a0complexity. \u00a0This \u00a0is \u00a0known \u00a0as\u00a0 \u00a0intuitive\u00a0 \u00a0expectation where modularization should not increase complexity.<\/span><\/p>\r\n\r\n<div style=\"text-align: justify\">\r\n\r\n<img class=\"aligncenter wp-image-287\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity.png\" alt=\"\" width=\"729\" height=\"324\" \/>\r\n\r\n<\/div>\r\n&nbsp;\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">STATEMENT COVERAGE\u00a0<\/strong>\r\n<div style=\"text-align: justify\">\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Statement Coverage requires that each statement will have been executed at least once. It is the simplest form of logic coverage and also known as Node Coverage. The given example shows the minimum number of test cases required to achieve statement coverage for the given program segment.<\/p>\r\n\r\n<\/div>\r\n<img class=\"aligncenter wp-image-286\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE.png\" alt=\"\" width=\"728\" height=\"335\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Another example to determine the complexity, where the given block code is:<\/span><\/p>\r\n\r\n<div style=\"text-align: justify\">\r\n\r\n&nbsp;\r\n\r\npublic void howComplex() {\r\n\r\nint i=20;\r\n\r\nwhile (i&lt;10) {\r\n\r\n&nbsp;\r\n\r\nSystem.out.printf(\"i is %d\", i);\r\n\r\nif (i%2 == 0) {\r\n\r\nSystem.out.println(\"even\");\r\n\r\n&nbsp;\r\n\r\n} else { System.out.println(\"odd\");\r\n\r\n}}}\r\n\r\n&nbsp;\r\n\r\nThe graph flow for the given block of code is given as follows, the complexity is given as follows;\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><strong>V (G) = 2 enclosed area + 1 = 3\u00a0<\/strong><\/p>\r\n&nbsp;\r\n\r\n<img class=\"aligncenter wp-image-285\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area.png\" alt=\"\" width=\"336\" height=\"330\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong>BRANCH COVERAGE\u00a0<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Branch Coverage requires that each branch will have been traversed, and that every program entry point will have been taken, at least once. It is also known as Edge Coverage. Branch coverage ensures that every program entry point will have been taken, at least once. Every branch is traversed to ensure that each branch is validated and does not exhibit any abnormal functionalities.<\/p>\r\n\r\n<\/div>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong><span style=\"text-align: initial;font-size: 1em\">Relationship between Statement and Branch Coverage:\u00a0<\/span><\/strong><\/p>\r\n\r\n<div style=\"text-align: justify\">\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Statement Coverage subsumes Branch Coverage (\u201cstatement =&gt; branch\u201d). <\/strong>If a program has \"dead (i.e., unreachable) code\", then \"statement coverage\" is unachievable. We would need to modify the program in order to bring the dead code back to \u201clife\u201d. The bottom line is that we will always assume the nominal case of \u201cno dead code\" unless explicitly stated otherwise. Under this assumption, Branch Coverage does indeed subsume Statement Coverage.<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>CONDITION COVERAGE\u00a0<\/strong>\r\n\r\n&nbsp;\r\n\r\nA branch predicate may have more than one condition. The given example shows condition coverage.\r\n\r\n&nbsp;\r\n\r\ninput(X,Y)\r\n\r\n&nbsp;\r\n\r\nif (Y&lt;=0) or (X=0) then\r\n\r\nY := -Y\r\n\r\nend_if\r\n\r\n&nbsp;\r\n\r\nwhile (Y&gt;0) and (not EOF) do\r\n\r\ninput(X)\r\n\r\nY := Y-1\r\n\r\n&nbsp;\r\n\r\nend_while\r\n\r\n&nbsp;\r\n\r\nCondition Coverage requires that each condition will have been true at least once and false at least once. For example:\r\n\r\n&nbsp;\r\n\r\nif <strong>A <\/strong>or <strong>B <\/strong>then s1\r\n\r\nelse\r\n\r\ns2 end_if_then_else\r\n\r\n&nbsp;\r\n\r\n<img class=\"aligncenter size-full wp-image-284\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/t1.png\" alt=\"\" width=\"422\" height=\"100\" \/>\r\n\r\n<\/div>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Branch\/Condition Coverage requires that both Branch AND Condition Coverage will have been achieved. Therefore, Branch\/Condition Coverage subsumes both Branch Coverage and Condition Coverage.<\/span><\/p>\r\n\r\n<div style=\"text-align: justify\">\r\n\r\n&nbsp;\r\n\r\n<strong>Summary of White-Box Coverage Relationships\u00a0<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe following figure depicts the white box coverage relationships:\r\n\r\n&nbsp;\r\n\r\n<img class=\"aligncenter wp-image-283\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships.png\" alt=\"\" width=\"621\" height=\"270\" \/>\r\n\r\n<strong>TESTING STRATEGIES\u00a0<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Many unanswered questions about white box and black box testing. E.g. who does the testing? Which techniques should we use and when? There are no universal strategies, just principles that have been useful in practice. E.g. the notions of unit testing and integration testing.<\/p>\r\n&nbsp;\r\n\r\n<strong>Basic Principles\u00a0<\/strong>\r\n<ul>\r\n \t<li>Testing starts at the component level and works \u201coutwards\u201d. Unit testing, integration testing and system testing.<\/li>\r\n \t<li>Different testing techniques are appropriate at different scopes.<\/li>\r\n \t<li>Testing is conducted by developers and\/or by a specialized group of testers.<\/li>\r\n \t<li>Testing is different from debugging. Debugging follows successful testing<\/li>\r\n<\/ul>\r\n<\/div>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Scope and Focus<\/strong><\/p>\r\n\r\n<ul style=\"text-align: justify\">\r\n \t<li><strong>Unit testing<\/strong>\r\n<ul>\r\n \t<li>Scope: individual com<\/li>\r\n \t<li>Focus: component corre<\/li>\r\n \t<li>Black-box and white-box techniques.<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li><strong>Integration testing<\/strong>\r\n<ul>\r\n \t<li>Scope: set of interacting com<\/li>\r\n \t<li>Focus: correctness of component interac<\/li>\r\n \t<li>Mostly black-box, some white-box<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li><strong>System testing<\/strong>\r\n<ul>\r\n \t<li>Scope: entire system.<\/li>\r\n \t<li>Focus: overall system<\/li>\r\n \t<li>Only black-box techniques.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>TEST-FIRST PROGRAMMING<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">Modern practices emphasize the importance of testing during development. \u00a0Testing during development reduces risks, ensures consistency and saves development costs<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Example: <\/strong>Test-first programming.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The basic idea before you start writing any code is first write the tests for this code. Write a little test code, write the corresponding unit code, make sure it passes the tests, and then repeat.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Advantages of Test-First Programming<\/strong><\/p>\r\n\r\n<ul>\r\n \t<li>Developers do not \u201cskip\u201d unit testing.<\/li>\r\n \t<li>Satisfaction for the programmer, the feeling of accomplishment when the tests pass.<\/li>\r\n \t<li>Helps clarify interface and behavior before programming. To write tests for something, first you need to understand it well.<\/li>\r\n \t<li>Software evolution.<\/li>\r\n \t<li style=\"text-align: justify\">After changing existing code, rerun the tests to gain confidence. (Regression testing).<\/li>\r\n<\/ul>\r\n&nbsp;\r\n\r\n<strong>Web Links<\/strong>\r\n<ul>\r\n \t<li>softwaretestingfundamentals.com\/white-box-testing\/<\/li>\r\n \t<li>www.softwaretestinghelp.com\/white-box-testing-techniques-with-example\/<\/li>\r\n \t<li>Www.softwaretestingclass.com\/white-box-testing\/<\/li>\r\n<\/ul>\r\n&nbsp;\r\n\r\n<strong>Supporting &amp; Reference Materials<\/strong>\r\n<ul>\r\n \t<li>Roger S. Pressman, \u201cSoftware Engineering: A Practitioner\u2019s Approach\u201d, Fifth Edition, McGraw Hill, 2001.<\/li>\r\n \t<li>Pankaj Jalote, \u201cAn Integrated Approach to Software Engineering\u201d, Second Edition, Narosa Publications, 2005.<\/li>\r\n \t<li>Ian Sommerville, \u201cSoftware Engineering\u201d, Tenth Edition, Pearson Education, 2017.<\/li>\r\n<\/ul>","rendered":"<div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>WHITE BOX TESTING<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">White box is a testing methodology to test the internal structures and working of software. White box testing also know as structural testing is testing based on analysis of internal logic (design, code, etc.).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>LEARNING OBJECTIVES\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 To focus on Program structures, Program internal logic and data structures, Program internal behaviors and states.<\/p>\n<p style=\"text-align: justify\">\u2022 To focus on internal program structure and discover all internal program errors.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Example Paths\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The following example shows the flow graph and the paths through the nodes, the example shows that the paths P3 and P4 are the same but they have different start and endpoints.<\/p>\n<\/div>\n<p style=\"text-align: justify\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-290\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths.png\" alt=\"\" width=\"749\" height=\"291\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths.png 1317w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths-300x116.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths-768x298.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths-1024x397.png 1024w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths-65x25.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths-225x87.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths-350x136.png 350w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/p>\n<div style=\"text-align: justify\">\n<p>&nbsp;<\/p>\n<p>In the example, the paths that form cycles are identified, where P4, P8, P9 does not form\u00a0<span style=\"text-align: initial;font-size: 1em\">cycles<\/span><strong style=\"text-align: initial;font-size: 1em\">.<\/strong><\/p>\n<\/div>\n<div style=\"text-align: justify\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-289\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1.png\" alt=\"\" width=\"732\" height=\"318\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1.png 1286w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1-300x130.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1-768x333.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1-1024x444.png 1024w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1-65x28.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1-225x98.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Example-Paths1-350x152.png 350w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>MODIFIED CYCLOMATIC COMPLEXITY MEASURES\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Given <em>p <\/em>connected components of a graph:<\/p>\n<table style=\"height: 70px; width: 382px;\">\n<tbody>\n<tr>\n<td style=\"width: 26.0625px\">\u25e6<\/td>\n<td style=\"width: 290.063px\">V(G) = e \u2013 n + 2p<\/td>\n<td style=\"width: 50.0625px\">(1)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 26.0625px\">\u25e6<\/td>\n<td style=\"width: 290.063px\">VLI(G) = e \u2013 n + p + 1<\/td>\n<td style=\"width: 50.0625px\">(2)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Eq. (2) is known as <em>linearly-independent <\/em>cyclomatic complexity. VLI does not change when program is modularized into <em>p <\/em>modules. A number of industry studies have indicated that the higher V(G), the higher the probability or errors.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-288\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range.png\" alt=\"\" width=\"403\" height=\"228\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range.png 403w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range-300x170.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range-65x37.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range-225x127.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Modules-in-this-range-350x198.png 350w\" sizes=\"auto, (max-width: 403px) 100vw, 403px\" \/><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">The following example shows computation of the cyclomatic complexity measures where modularization \u00a0does \u00a0not \u00a0increase \u00a0complexity. \u00a0This \u00a0is \u00a0known \u00a0as\u00a0 \u00a0intuitive\u00a0 \u00a0expectation where modularization should not increase complexity.<\/span><\/p>\n<div style=\"text-align: justify\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-287\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity.png\" alt=\"\" width=\"729\" height=\"324\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity.png 1242w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity-300x133.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity-768x341.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity-1024x455.png 1024w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity-65x29.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity-225x100.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/not-increase-complexity-350x156.png 350w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">STATEMENT COVERAGE\u00a0<\/strong><\/p>\n<div style=\"text-align: justify\">\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Statement Coverage requires that each statement will have been executed at least once. It is the simplest form of logic coverage and also known as Node Coverage. The given example shows the minimum number of test cases required to achieve statement coverage for the given program segment.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-286\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE.png\" alt=\"\" width=\"728\" height=\"335\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE.png 1187w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE-300x138.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE-768x354.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE-1024x472.png 1024w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE-65x30.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE-225x104.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/STATEMENT-COVERAGE-350x161.png 350w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Another example to determine the complexity, where the given block code is:<\/span><\/p>\n<div style=\"text-align: justify\">\n<p>&nbsp;<\/p>\n<p>public void howComplex() {<\/p>\n<p>int i=20;<\/p>\n<p>while (i&lt;10) {<\/p>\n<p>&nbsp;<\/p>\n<p>System.out.printf(&#8220;i is %d&#8221;, i);<\/p>\n<p>if (i%2 == 0) {<\/p>\n<p>System.out.println(&#8220;even&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>} else { System.out.println(&#8220;odd&#8221;);<\/p>\n<p>}}}<\/p>\n<p>&nbsp;<\/p>\n<p>The graph flow for the given block of code is given as follows, the complexity is given as follows;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><strong>V (G) = 2 enclosed area + 1 = 3\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-285\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area.png\" alt=\"\" width=\"336\" height=\"330\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area.png 491w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area-300x295.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area-65x64.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area-225x221.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/enclosed-area-350x344.png 350w\" sizes=\"auto, (max-width: 336px) 100vw, 336px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>BRANCH COVERAGE\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Branch Coverage requires that each branch will have been traversed, and that every program entry point will have been taken, at least once. It is also known as Edge Coverage. Branch coverage ensures that every program entry point will have been taken, at least once. Every branch is traversed to ensure that each branch is validated and does not exhibit any abnormal functionalities.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong><span style=\"text-align: initial;font-size: 1em\">Relationship between Statement and Branch Coverage:\u00a0<\/span><\/strong><\/p>\n<div style=\"text-align: justify\">\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Statement Coverage subsumes Branch Coverage (\u201cstatement =&gt; branch\u201d). <\/strong>If a program has &#8220;dead (i.e., unreachable) code&#8221;, then &#8220;statement coverage&#8221; is unachievable. We would need to modify the program in order to bring the dead code back to \u201clife\u201d. The bottom line is that we will always assume the nominal case of \u201cno dead code&#8221; unless explicitly stated otherwise. Under this assumption, Branch Coverage does indeed subsume Statement Coverage.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>CONDITION COVERAGE\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>A branch predicate may have more than one condition. The given example shows condition coverage.<\/p>\n<p>&nbsp;<\/p>\n<p>input(X,Y)<\/p>\n<p>&nbsp;<\/p>\n<p>if (Y&lt;=0) or (X=0) then<\/p>\n<p>Y := -Y<\/p>\n<p>end_if<\/p>\n<p>&nbsp;<\/p>\n<p>while (Y&gt;0) and (not EOF) do<\/p>\n<p>input(X)<\/p>\n<p>Y := Y-1<\/p>\n<p>&nbsp;<\/p>\n<p>end_while<\/p>\n<p>&nbsp;<\/p>\n<p>Condition Coverage requires that each condition will have been true at least once and false at least once. For example:<\/p>\n<p>&nbsp;<\/p>\n<p>if <strong>A <\/strong>or <strong>B <\/strong>then s1<\/p>\n<p>else<\/p>\n<p>s2 end_if_then_else<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-284\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/t1.png\" alt=\"\" width=\"422\" height=\"100\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/t1.png 422w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/t1-300x71.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/t1-65x15.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/t1-225x53.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/t1-350x83.png 350w\" sizes=\"auto, (max-width: 422px) 100vw, 422px\" \/><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Branch\/Condition Coverage requires that both Branch AND Condition Coverage will have been achieved. Therefore, Branch\/Condition Coverage subsumes both Branch Coverage and Condition Coverage.<\/span><\/p>\n<div style=\"text-align: justify\">\n<p>&nbsp;<\/p>\n<p><strong>Summary of White-Box Coverage Relationships\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The following figure depicts the white box coverage relationships:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-283\" src=\"http:\/\/csp8.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships.png\" alt=\"\" width=\"621\" height=\"270\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships.png 1202w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships-300x130.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships-768x334.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships-1024x445.png 1024w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships-65x28.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships-225x98.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-content\/uploads\/sites\/53\/2018\/07\/Summary-of-White-Box-Coverage-Relationships-350x152.png 350w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/p>\n<p><strong>TESTING STRATEGIES\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Many unanswered questions about white box and black box testing. E.g. who does the testing? Which techniques should we use and when? There are no universal strategies, just principles that have been useful in practice. E.g. the notions of unit testing and integration testing.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Basic Principles\u00a0<\/strong><\/p>\n<ul>\n<li>Testing starts at the component level and works \u201coutwards\u201d. Unit testing, integration testing and system testing.<\/li>\n<li>Different testing techniques are appropriate at different scopes.<\/li>\n<li>Testing is conducted by developers and\/or by a specialized group of testers.<\/li>\n<li>Testing is different from debugging. Debugging follows successful testing<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Scope and Focus<\/strong><\/p>\n<ul style=\"text-align: justify\">\n<li><strong>Unit testing<\/strong>\n<ul>\n<li>Scope: individual com<\/li>\n<li>Focus: component corre<\/li>\n<li>Black-box and white-box techniques.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Integration testing<\/strong>\n<ul>\n<li>Scope: set of interacting com<\/li>\n<li>Focus: correctness of component interac<\/li>\n<li>Mostly black-box, some white-box<\/li>\n<\/ul>\n<\/li>\n<li><strong>System testing<\/strong>\n<ul>\n<li>Scope: entire system.<\/li>\n<li>Focus: overall system<\/li>\n<li>Only black-box techniques.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>TEST-FIRST PROGRAMMING<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Modern practices emphasize the importance of testing during development. \u00a0Testing during development reduces risks, ensures consistency and saves development costs<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Example: <\/strong>Test-first programming.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The basic idea before you start writing any code is first write the tests for this code. Write a little test code, write the corresponding unit code, make sure it passes the tests, and then repeat.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Advantages of Test-First Programming<\/strong><\/p>\n<ul>\n<li>Developers do not \u201cskip\u201d unit testing.<\/li>\n<li>Satisfaction for the programmer, the feeling of accomplishment when the tests pass.<\/li>\n<li>Helps clarify interface and behavior before programming. To write tests for something, first you need to understand it well.<\/li>\n<li>Software evolution.<\/li>\n<li style=\"text-align: justify\">After changing existing code, rerun the tests to gain confidence. (Regression testing).<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Web Links<\/strong><\/p>\n<ul>\n<li>softwaretestingfundamentals.com\/white-box-testing\/<\/li>\n<li>www.softwaretestinghelp.com\/white-box-testing-techniques-with-example\/<\/li>\n<li>Www.softwaretestingclass.com\/white-box-testing\/<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Supporting &amp; Reference Materials<\/strong><\/p>\n<ul>\n<li>Roger S. Pressman, \u201cSoftware Engineering: A Practitioner\u2019s Approach\u201d, Fifth Edition, McGraw Hill, 2001.<\/li>\n<li>Pankaj Jalote, \u201cAn Integrated Approach to Software Engineering\u201d, Second Edition, Narosa Publications, 2005.<\/li>\n<li>Ian Sommerville, \u201cSoftware Engineering\u201d, Tenth Edition, Pearson Education, 2017.<\/li>\n<\/ul>\n","protected":false},"author":4,"menu_order":28,"template":"","meta":{"_acf_changed":false,"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["dr-r-baskaran"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-279","chapter","type-chapter","status-publish","hentry","contributor-dr-r-baskaran"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/chapters\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/wp\/v2\/users\/4"}],"version-history":[{"count":6,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/chapters\/279\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/chapters\/279\/revisions\/412"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/chapters\/279\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/pressbooks\/v2\/chapter-type?post=279"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/wp\/v2\/contributor?post=279"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp8\/wp-json\/wp\/v2\/license?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}