10
Develop test cases for white box testing White box testing uses the internal mechanism of a system to create test cases, which uses calculated paths to discover unidentified bugs within the system. This type of testing is trying to enforce the quality of the software system however “white box testing” is a cost effective method and is compared very closely to “Black box testing”. The main jobs of these two functions have the same purpose however it is majorly debated which one is more efficient and effective. Black box testing concentrates mainly on the outputs of the system to identify bugs however this function waits till a malfunctioning error has occurred. As explained above White box testing is used to ensure that the code is complete and to the correct standard of the software mechanism. Statistics haves proven that by using a complete and precise systematic test design, will ensure that the majority of bugs within the system will be identified. When looking at white box testing in more detail it involves checking and ensuring that every program statement is error free. White box testing allows: Data Processing Calculation correctness tests Software Qualification tests Maintainability tests Reusability tests Data Processing and Calculation Correctness tests Within the main two concepts of Calculation Correctness tests and Data processing, when a test case has been created (path) it is then proceeded to be tested and verified which will ensure the correctness of the software program. This procedure is done in sequence for every test case created, this gives the user the opportunity to test whether the code / program has been implemented correctly to the requirements / specification. Software Qualification tests

white box testing project

Embed Size (px)

DESCRIPTION

white box test cases project

Citation preview

Develop test cases for white box testingWhite box testing uses the internal mechanism of a system to create test cases, which uses calculated paths to discover unidentified bugs within the system. This type of testing is trying to enforce the quality of the software system however white box testing is a cost effective method and is compared very closely to Blac box testing. The main !obs of these two functions have the same purpose however it is ma!orly debated which one is more efficient and effective. Blac box testing concentrates mainly on the outputs of the system to identify bugs however this function waits till a malfunctioning error has occurred. "s explained above White boxtesting is used to ensure that the code is complete and to the correct standard of the software mechanism. #tatistics haves proven that by using a complete and precise systematic test design, will ensure that the ma!ority of bugs within the system will be identified. When looing at white box testing in more detail it involves checing and ensuring that every program statement is error free. White box testing allows$ %ata &rocessing 'alculation correctness tests #oftware (ualification tests )aintainability tests *eusability testsData Processing and Calculation Correctness testsWithin the main two concepts of 'alculation 'orrectness tests and %ata processing, when a test case has been created +path, it is then proceeded to be tested and verified which will ensure the correctness of the software program. This procedure is done in sequence for every test case created, this gives the user the opportunity to test whetherthe code - program has been implemented correctly to the requirements - specification. Software Qualification testsWhen going through the software qualification tests it loos directly to the software code itself. This tests wors with the coding standards and wor instructions set by the client or developer. Maintainability testsThe maintainability tests installs special features to detect failures, module structures that support software development, extensions and improvements of the software system. The reusability tests is part of an example of this, as explained below$Reusability tests*eusability tests are performed on the pacage which examines all of the reused software that had been implemented into the software pacage. "ddition to this function it also adapts to the program allowing the present code to be re.usable for future preferences. When looing at the White box testing in more detail and analysing its procedures it becomes aware that when testing each test case - path maybe become unrealistic and unfeasible. We have to tae into account on the amount of coverage of all the possiblepaths and the amount of code that is produced. There are two possible solutions for this situation$ Line Coverage / this is to test and cover over all of the program code and the coverage is calculated by the percentage of lines covered. Path Coverage / this is to test and cover all the available paths in the system and the coverage is calculated by the percentage of paths covered.Correctness tests and Path coverage&ath testing0s main goal is to go through the system covering all possible paths, this istested with all condition such as 12.T345.46#4 and %7 W3164 statements. To taewhite box into account it is very impractical due to the amount of resources needed for this type of testing. &ath testing is used from the start of a method to when it finishes, each path shows the flow of execution. By looing at white box complete path coverage will show how extreme this type of testing is$Example:There is a software pacage that contains five conditional statements which will only for this example allow two procedures eg 12.T345.46#4, %7 W3164. When following this type of code, it is expected that it will contain over 89: paths +:8 / 8; lines of code,, therefore at least 89: test cases should be performed ensuring each path has been covered. raph 5otation" flow diagram to show how car insurance can be calculated based on the users circumstances. This diagram involves$" 'ar 1nsurance 'ompany and calculating the users annual car insurance will involve$ 1f the users car is less then ?9;,;;; or greater then, 1s the year of the car older then 8 years, 3ow old is the user, %oes the user have any previous driving experience, %oes the user have more then two years no claims bonus.1Car Insurance@9@9;9:@ABC99 Dears 4xperience : 'ar price8 Dear of 'arE 3ow old are youF=9C, G:H no claims bonus17Calculate Car Insurance6ess then ?9;,;;;Older then5 Years >reater then ?9;,;;;6ess Then 8 DearsDounger then :87lder then or I :86ess then 9 Dear )ore then 9 year5one)ore then : years ncb98@9=@2rom this diagram is possible to come out with another of different unique paths. 7verall to achieve complete path coverage an estimated :C test cases would have to be performed due to their being :C individual unique paths.4xamples of unique paths have been displayed below. 'omplete 2ull &ath 'overage 9 I9.:[email protected].=.E.A.99.9:.9B : I9.:[email protected][email protected] @ I9.:[email protected][email protected]= C I9.:[email protected].=.E.9;.99.9B J 9@ I 9.:.C.8.=.E.A.99.9:.9B 9C I 9.:[email protected] J :@ I 9.:.C.8.B.E.9;[email protected] :C I 9.:.C.8.B.E.9;[email protected]=.9BBy looing at this scenario, if the entities and modules increased the amount of testingto be performed on this would grow rapidly. The increase in modules would then lead to a more complex system. " scientist called )c'abe then come up with a theory to determine how complex a software system was and how easy it was to interoperate this type of software system.!ndependent Progra" PathsMcCabes Cyclomatic Complexity Metrics"s explained above )c'abes theory was to find out how complex a system was and how much testing would be sufficient in order to complete white box testing. )c'abecame up with a formula to distinguish the complexity, and this was done by measuring the number of independent paths needed to achieve full line coverage. Thisstrategy would be based on taing the characteristics of the flow diagram and placing this information into the formula. "n example of this is shown below$)c'abes formulae$ K+>, I * K +>, I 4 /5 H : K+>, I & H 9* I The number of regions that is involved in the program flow graph. +"ny enclosed area including the outer layer of the flow diagram.,4 I The number of edges5 I The number of nodes& I The number of decisions 1 have now taen )c'abes theory and have applied it to our 'ar 1nsurance #cenario$Applying McCabes theories. *ed 'ircles indicate the regions within our car insurance exampleThe amount of arrows subtracted by the number of nodesThe diamond shapes are represented as & as they are decision entities. 7ur 4xample K+>, I = K+>, I :9 .9B H : I = K+>, I 8 H 9 I = *esulting metrics calculations indicate that the maximum number of independent paths needed to achieve full line coverage is =. To summarise )ccabes ob!ective is that programs with cyclomatic complexities of less then 8 are simple and easy to understand, :;H independent paths needed results in the complexity is perceived as high and extreme testing would have to be performed. "lso any program containing 8; and above the software for practical purposes becomes nown unpractical maybe even impossible.! Prepare test cases that will force execution of each path in the basis set!#! Condition TestingCondition testingis atest.casedesignmethodthatexercises thelogicalconditionscontainedina programmodule. "simple conditionis a Booleanvariable or arelational expression, possiblyprecededwithone57T+L, operator. "relationalexpression taes the formE9 Mrelational.operatorG E:where E9 and E: are arithmetic expressions and Mrelational.operatorG is one of thefollowing$ M,G,N, O+nonequality,, I, or P. " compound condition is composed of twoor more simple conditions, Booleanoperators, andparentheses. Weassume thatBoolean operators allowed in a compound condition include 7* , "5% +Q,, and 57T+L,. " condition without relational expressions is referred to as a Boolean expression.1f a condition is incorrect, then at least one component of the condition is incorrect.Therefore, types of errors in a condition include Boolean operator errorsincorrect-missing-extra Boolean operators,, Boolean variable errors, Booleanparenthesis errors, relational operator errors, and arithmetic expression errors. Thecondition testing method focuses on testing each condition in the program to ensurethat it does not contain errors$dvantages of %hite &ox Testing1ntrospection / this gives the user or tester the opportunity to test internally which allows a better perspective of ob!ects and modules within the software. This is effective when the >raphical user 1nterface is changing frequently. 1dentification / By going through each line the test is able to reveal what test cases have been applied to what ob!ect and lists the number of lines that have not yet been executed. 4ffectiveness / This type of testing gives the end user or the supplier the confidence that every path has been tested to a certain extent, which should limit the amount of bugs within an application. White box testing is the most effective testing as it the most thorough when testing an individual application.Disadvantages of %hite &ox Testing" silled and trained tester will be needed to perform this type of testing. This type of testing requires a certain level of sill, ensuring that every path and test case has been examined at least once. This type of testing is time consuming and may be very cost effective."lso it has been said that it is nearly impossible to loo into every bit of code within the infrastructure to find all possible errors.