Connect with us

Blog

White Box Testing and its Types

Published

on

White box testing

Testing each and every line of the code is called WHITE BOX TESTING. It is done by the developers. White box testing is also known as (Open box testing, Glass box testing, Unit testing, Transparent testing, Structural testing, Mutation testing, and Code-based testing).

Here developer will look into the source code and check whether each and every line of the program is working as expected or not. Since the code is visible to the developer, it is called white box testing or glass box testing. It is first testing done in SDLC (Software Development Life Cycle) 

White box testing Types

The 5 types of white box testing are listed below:

  1. Path testing
  2. Conditional testing
  3. Loop testing
  4. Unit testing
  5. Testing the code from the memory point of view
  6. Testing the code from the performance point of view

Path testing

PATH TESTING is an approach where developers will write the flow chart and test each & every individual path and make sure that every path has been executed at least once. Path testing is done to identify all the individual path in the code. Path testing is also called as cyclomatic complexity.

In path testing first, you will find the starting part of the path or block and travel through the code to find the end path. And in this way, you will find one individual path.
However, while doing path testing you might not find a bug in the code but surely helps to add better logic and processing to the code. After all most of the bud arises because of wrong processing code and doing path testing helps you to correct them.

Let me explain path testing with an example

type of white box testing

In the above example, it shows a simple WhatsApp working path. In the diagram, WhatsApp is considered as the main feature and under that feature, there are various other functions like chats, status, and calls. Like that, features are again divided. Now from this, various paths can be drawn, such as:

Path 1: main () – func 1() – func 4()
Path 2: main () – func 1() – func 5()
Path 3: main () – func 1() – func 6()
Path 4: main () – func 2() – func 7()
Path 5: main () – func 3() – func 8()
Path 6: main () – func 3() – func 9()

The developer writes the code so that codes can work and satisfies the above path by giving no errors. In Path 1, it shows that main () program is divided into subprograms as chats, status & calls. Again, subprogram, chats () is divided into two subprograms as text () and video ().

According to above example, developers will take one sheet, write the flow chart and he will identify each and every individual path. And later the developer will set the parameters for the main program and starts to test each and every path. In this way, the developer will check for various paths by passing parameters to the codes.

Chances are there while doing path testing developers might find defect like some of the path might not work while passing input to the codes.
Now the developer will fix the defect and test the entire path again, this is how the developer will do path testing.

Conditional testing

CONDITIONAL TESTING is done to check for the logical conditions i.e. for the true and false condition. This testing is also known as predicate testing.

Let me explain this with an example

type of white box testing

The above diagram shows the signup page of an application. Developers have written the codes and developed this signup page. And for the ‘Female’ and ‘Male’ radio buttons, he wrote code by applying “if condition”.

Now here he has to check for the conditions as, “If the condition is true, run certain pieces of codes and if the condition is false, then run other pieces of codes.”

Here you will check conditions for both true and false conditions because chances are there sometimes the code might work for true condition and it might not run for false condition and vice versa. So, to make sure that the code is working for both true and false conditions, you have to do conditional testing.

Read here: What-why-when-How of System Testing 

Loop testing

Loop testing is the type of white box testing where you will test the loop and make sure that loop is repeating for a defined number of the cycle.
In this testing, you will also make sure that the terminating condition used is working properly or not.

Example to understand loop testing

type of white box testing

In the above example, the developer has used ‘while’ loop. And this loop should repeat for 10 times as mentioned in above dummy code written. Suppose if it’s repeating only for 6 times and loop fails. Then it is an error in the program.

The developer will fix the error and test the loop for 10 times to check whether it is working or not. This is how you will do loop testing.

Suppose if the loop is written to repeat for 1 lakhs time, then testing loop manually for one lakhs time is a very tough job and in this case, you will go for automation.

Unit testing

UNIT TESTING is a type of white box testing in which you will isolate the particular section of code and check for its correctness. Unit testing is done by the developers. And this is also first testing done in the levels of software testing.

How unit testing is done?

Unit testing is done by the developers. Firstly when a customer gives the requirement, developers will write the main program for the requirement and corresponding test program in the same language. This test program will invoke the main program and will test the main program and finally give the result as pass or fail.

Here the developer will take one individual component and he will test whether it is working as per the design or not. In this way, unit testing is done.

Take a look at below given example to understand how unit testing is done.

Let’s suppose the customer has given requirement to develop three modules i.e. module A, module B, and module C.

unit testing example

Now the developer will write the code to develop these three modules i.e. the main program and even he will write the corresponding test program in order to test the main program.

Finally, he will run the test program against the main program, and the test program will invoke the main program. And this test will test the main program in order to find an error in the code. So, this how you will perform unit testing. And the collection of all the test program is called a test suite or unit test suite.

Now if you see there when the test program is run against the main program, it introduces 3 cases

Case 1

Assume that error is in the test program

Suppose if the error is in the test program, the developer will fix the error in the test program and run the test program against the main program.

Case 2

Assume that error is in the main program

The developer will fix the error in the main program and run the corresponding test program against the main program. But chances are there while fixing a defect in the main program it might have affected other main programs. So, the developer will run the entire test suite.

Case 3

Assume that customer changed the requirement

For example, customer changes requirement in module A. Then developer will modify main program and corresponding test program for module A and run the test program against the main program for A. But chance are there while making changes in module A, it might have impacted other modules i.e. B & C. So, developer will run the entire unit test suite.

Testing the code from the memory point of view

  • By changing the logic of the program, you can improve memory because writing logic varies from person to person.

    For example, you wrote codes to develop a certain webpage and it consumed around 2 GB memory space. In another hand, the same webpage is created by one senior developer which is consuming around 1.5 GB memory space. Because he wrote codes by applying good logic. And hence it saved the memory.

  • By removing unwanted functions and unused command from the program, you can improve the memory.
  • If there is a repetition of the same code or duplicate codes then you should convert the code into a generic function, user-defined function.
  • And by removing dead code from the program, you can improve the memory.
  • By using inbuilt functions, you can improve memory.
  • By removing unused variables, you can improve memory.
  • Tool name Rational purifier is basically used to test the program from a memory point of view.

Testing the codes from the performance point of view

  • You can improve the performance of the code by writing good logic.
  • Instead of using ‘nested if’, you should go for the ‘switch statement’.
  • ‘AND’ or ‘OR’ operations should be properly used while writing conditional cases.
  • Tool name Rational Quantifier is basically used to test the program from a performance point of view.

Why is white box testing required?

White box testing is required to test the structure and working flow of the code. It is mainly required for code optimization. Moreover, the developer will get confidence in his code after doing white box testing. So that he can give the software to test engineers for black box testing.

Difference between what is Black Box Testing and White Box Testing

Below are some of the difference between black box testing and white box testing:

 

Advantages of white box testing

Here are some of the advantages of white box testing 

  1. It helps in code optimization.
  2. It helps to find defects in the code.
  3. Helps developer to come up with logical coding.

Disadvantages of White box testing

Some of the disadvantages of white box testing are given below:

  1. It is highly costly and time-consuming.
  2. One should have the very good programming knowledge to perform white box testing.
  3. The developer needs to have knowledge of Internal design.

Conclusion

White box testing is the first testing which is done by the developers once they finishing writing the codes. After doing white box testing they can make sure that software does not break in the initial stage of the further testing process.

Don’t miss the latest articles:

I am a writer at Shouthow. Keeping updates with a current affair is my main interest. Contact me at officialshouthow@gmail.com

Advertisement
Advertisement

Lastest Posts

sdmoviespoint sdmoviespoint
About2 months ago

Sdmoviespoint 2019 – Download Tamil, Hindi Telugu Movies for Free

Sdmoviespoint. cc 2019: Sdmoviespoint is another famous illegal movie downloading website mainly known in Asian countries. This website uploads all...

katmovies katmovies
About2 months ago

Katmovie 2019: Download New Bollywood, Hollywood, Tamil, Telugu Movies

Katmovies 2019: Katmovie is a world-famous illegal movie downloading website. It leaks most of the highest-grossing Bollywood, Hollywood, Telugu, and...

moviesda moviesda
About2 months ago

Moviesda 2019: Download Moviesda Tamil, Telugu, Hindi Movies Online

Moviesda 2019: In the world of movie piracy website, Moviesda just stands behind Tamilrockers. This proves Moviesda as the most...

horriblesubs horriblesubs
About2 months ago

Horriblesubs 2019 – Free Download Anime Series from Horriblesubs

Horriblesubs is a popular website to watch and download anime series. It facilitates you with downloading anime series in your...

movieswood movieswood
About2 months ago

MoviesWood 2019 – Download Telugu, Tamil, Malayalam, Hindi Movies

Movieswood. me 2019: Movieswood is one of the most notorious websites just like Filmywap, which uploads pirated content. Pirated contents...

downloadhub. ws downloadhub. ws
About3 months ago

Downloadhub 2019 – 300 MB Dual Audio Bollywood Movies Download

Downloadhub. ws 2019 – Downloadhub is a famous dual audio pirated movie downloading website. This notorious website is famous among...

tamilmv tamilmv
About3 months ago

TamilMv 2019 – Download Tamil, Telugu, Malayalam, Hindi movies online

TamilMv 2019 – TamilMv is an illegal pirated movie downloading site which is operated all over the world. The site...

dvdwap dvdwap
About3 months ago

DVD Rockers 2019 | DVD Rockers net – Download Kannada, Telugu Movies

DVD Rockers is a similar website like Tamilrockers which release the pirated movies. It is mainly known for leaking Kannada...

filmywap filmywap
About3 months ago

Filmywap 2019: Download Hollywood, Bollywood, Punjabi Movies Online

Filmywap is increasing its popularity in leaking the high grossing Bollywood, Hollywood as well as Punjabi movies. Filmywap.com is the official...

isaimini isaimini
About4 months ago

Isaimini Movies 2019 |Download Tamil, Telugu Movies and Mp3 Song

Isaimini is the most notorious and very famous illegal movie torrenting website. It leaks almost all movies like new Tamil...

Trending