Wednesday 26 March 2014

DIFFERENCE BETWEEN WHITE BOX TESTING AND BLACK BOX TESTING

       
Difference between white box testing and black box testing
White box testing:
          White box testing strategy deals with the internal logic and structure of the code. White box testing is also called as glass, structural, open box or clear box testing. The tests written based on the white box testing strategy incorporate coverage of the code written, branches, paths, statements and internal logic of the code etc.
In order to implement white box testing, the tester has to deal with the code and hence is needed to possess knowledge of coding and logic i.e. internal working of the code. White box test also needs the tester to look into the code and find out which unit/statement/chunk of the code is malfunctioning.

Advantages of white box testing:
i) As the knowledge of internal coding structure is a prerequisite, it becomes very easy to find out which type of input/data can help in testing the application effectively.
ii) The other advantage of white box testing is that it helps in optimizing the code.
iii) It helps in removing the extra lines of code, which can bring in hidden defects.
Disadvantages of white box testing:
i) As knowledge of code and internal structure is a prerequisite, a skilled tester is needed to carry out this type of testing, which increases the cost.
ii) It is nearly impossible to look into every bit of code to find out hidden errors, which may create problems, resulting in failure of the application.
Types of white box testing:
(1) Unit Testing : The developer carries out unit testing in order to check if the particular module or unit of code is working fine. The Unit Testing comes at the very basic level as it is carried out as and when the unit of the code is developed or a particular functionality is built.
(2) Static and Dynamic Analysis : Static analysis involves going through the code in order to find out any possible defect in the code. Dynamic analysis involves executing the code and analyzing the output.
(3) Statement Coverage : In this type of testing the code is executed in such a manner that every statement of the application is executed at least once. It helps in assuring that all the statements are executed without any side effect.
(4) Branch Coverage : No software application can be written in a continuous mode of coding, at some point we need to branch out the code in order to perform a particular functionality. Branch coverage testing helps in validating of all the branches in the code and making sure that no branching leads to abnormal behaviour of the application.
(5) Security Testing : Security Testing is carried out in order to find out how well the system can protect itself from unauthorized access, hacking – cracking, any code damage etc. which deals with the code of application. This type of testing needs sophisticated testing techniques.
(6) Mutation Testing : A kind of testing in which, the application is tested for the code that was modified after fixing a particular bug/defect. It also helps in finding out which code and which strategy of coding can help in developing the functionality effectively.

Besides all the testing types given above, there are some more types which fall under both Black box and White box testing strategies such as: Functional testing (which deals with the code in order to check its functional performance), Incremental integration testing (which deals with the testing of newly added code in the application), Performance and Load testing (which helps in finding out how the particular code manages resources and give performance etc.).


 Black Box Testing:
 Black Box Testing is testing without knowledge of the internal working of the item being tested. For example, when black box testing is applied to software engineering, the tester would only know the "legal" inputs and what the expected outputs should be, but not how the program actually arrives at those outputs. It is because of this that black box testing can be considered testing with respect to the specifications, no other knowledge of the program is necessary. For this reason, the tester and the programmer can be independent of one another, avoiding programmer bias towards his own work. Also, due to the nature of black box testing, the test planning can begin as soon as the specifications are written.
Example:
int a=30000,b=30000,c;
c=a+b;
You know that result of c is 60000. But is the answer right or wrong? Though the answer is right, it is actually wrong from the point of view of int data type. Do you remember the range of int?
It is -32768 to +32767.
From the above point it is clear that inputs a,b come within the range of int but not the output as it exceeds the maximum range of int. So such things will be checked in black box testing.

Advantages of Black box testing:
more effective on larger units of code than glass box testing.
tester needs no knowledge of implementation, including specific programming languages.
·         tester and programmer are independent of each other.
tests are done from a user's point of view.
will help to expose any ambiguities or inconsistencies in the specifications.
test cases can be designed as soon as the specifications are complete.
Disadvantages of Black Box Testing -
only a small number of possible inputs can actually be tested, to test every possible input stream would take nearly forever.
without clear and concise specifications, test cases are hard to design.
there may be unnecessary repetition of test inputs if the tester is not informed of test cases the programmer has already tried.
may leave many program paths untested.
cannot be directed toward specific segments of code which may be very complex (and therefore more error prone).
most testing related research has been directed toward glass box testing.

1 comment:

  1. It is very useful and covers the whole topic about BBT and WBT.
    would you please give the questions on discrete structures (MCQS + theory)?

    ReplyDelete