TrainingConferencesAbout UsContact UsAdvertiseSQE.comRSS Feed

StickyMinds.com: brain food for building better software

Log In
 Clarify Your Search Criteria

Tips on Using Our Search Feature(s)
 
StickyMinds.com Home
ResourcesTopicsCommunityPowerPassBlogs
Home  >  Detail: Five Ways to Think about Black Box Testing



A StickyMinds.com Original
Article Picture
Five Ways to Think about Black Box Testing

By Bret Pettichord

Send This Content to a FriendGet a Short Link to This ContentPrint This ContentSee User Comments About This Content

Summary: Have you ever seen a software testing discussion erupt into a debate over the definition of black box testing, or the difference between black box and white box testing? It seems lots of people have lots of ideas about what the terms really mean. Columnist Bret Pettichord uses the five dimensions of testing to examine black box and white box testing. And he leaves you with a few puzzles to consider.


HP
An easy way to start up a debate in a software testing forum is to ask the difference between black box and white box testing. These terms are commonly used, yet everyone seems to have a different idea of what they mean.  
 
Black box testing begins with a metaphor. Imagine you’re testing an electronics system. It’s housed in a black box with lights, switches, and dials on the outside. You must test it without opening it up, and you can’t see beyond its surface. You have to see if it works just by flipping switches (inputs) and seeing what happens to the lights and dials (outputs). This is black box testing. Black box software testing is doing the same thing, but with software. The actual meaning of the metaphor, however, depends on how you define the boundary of the box and what kind of access the “blackness” is blocking. 
 
An opposite test approach would be to open up the electronics system, see how the circuits are wired, apply probes internally and maybe even disassemble parts of it. By analogy, this is called white box testing, but already the metaphor is faulty. It is just as hard to see inside a white box as a black one. In the interests of logic, some people prefer the term “clear box” testing, but even a clear box keeps you from probing the internals of the system. It might be even more logical to call it “no box” testing. But the metaphor operates beyond logic. Since “white box” testing is the most common term, I’ll use it here. 
 
To help understand the different ways that software testing can be divided between black box and white box techniques, I’ll use the Five-Fold Testing System. It lays out five dimensions that can be used for examining testing:  
 
1. People (who does the testing) 
2. Coverage (what gets tested) 
3. Risks (why you are testing) 
4. Activities (how you are testing) 
5. Evaluation (how you know you’ve found a bug) 
 
Let’s use this system to understand and clarify the characteristics of black box and white box testing. 
 
People: Who does the testing? 
Some people know how software works (developers) and others just use it (users). Accordingly, any testing by users or other nondevelopers is sometimes called “black box” testing. Developer testing is called “white box” testing. The distinction here is based on what the person knows or can understand. 
 
Coverage: What is tested? 
If we draw the box around the system as a whole, “black box” testing becomes another name for system testing. And testing the units inside the box becomes white box testing. This is one way to think about coverage.  
 
Another is to contrast testing that aims to cover all the requirements with testing that aims to cover all the code. These are the two most commonly used coverage criteria. Both are supported by extensive literature and commercial tools. Requirements-based testing could be called “black box” because it makes sure that all the customer requirements have been verified. Code-based testing is often called “white box” because it makes sure that all the code (the statements, paths, or decisions) is exercised.  
 
Risks: Why are you testing? 
Sometimes testing is targeted at particular risks. Boundary testing and other attack-based techniques are targeted at common coding errors. Effective security testing also requires a detailed understanding of the code and the system architecture. Thus, these techniques might be classified as “white box.” 
 
Another set of risks concerns whether the software will actually provide value to users. Usability testing focuses on this risk, and could be termed “black box.” 
 
Activities: How do you test? 
A common distinction is made between behavioral test design, which defines tests based on functional requirements, and structural test design, which defines tests based on the code itself. These are two design approaches. Since behavioral testing is based on external functional definition, it is often called “black box,” while structural testing—based on the code internals—is called “white box.” Indeed, this is probably the most commonly cited definition for black box and white box testing. 
 
Another activity-based distinction contrasts dynamic test execution with formal code inspection. In this case, the metaphor maps test execution (dynamic testing) with black box testing, and maps code inspection (static testing) with white box testing. 
 
We could also focus on the tools used. Some tool vendors refer to code-coverage tools as white box tools, and tools that facilitate applying inputs and capturing inputs—most notably GUI capture replay tools—as black box tools. Testing is then categorized based on the types of tools used. 
 
Evaluation: How do you know if you’ve found a bug? 
There are certain kinds of software faults that don’t always lead to obvious failures. They may be masked by fault tolerance or simply luck. Memory leaks and wild pointers are examples. Certain test techniques seek to make these kinds of problems more visible. Related techniques capture code history and stack information when faults occur, helping with diagnosis. Assertions are another technique for helping to make problems more visible. All of these techniques could be considered white box test techniques, since they use code instrumentation to make the internal workings of the software more visible. These contrast with black box techniques that simply look at the official outputs of a program. 
 
To summarize, black box testing can sometimes describe user-based testing (people); system or requirements-based testing (coverage); usability testing (risk); or behavioral testing or capture replay automation (activities). White box testing, on the other hand, can sometimes describe developer-based testing (people); unit or code-coverage testing (coverage); boundary or security testing (risks); structural testing, inspection or code-coverage automation (activities); or testing based on probes, assertions, and logs (evaluation). 
 
Puzzles 
So now that we’ve examined some ways to think about the differences between black box and white box testing, let me leave you with a few puzzles. Let’s hear what you think.  
 
A. A programmer tests a class to ensure that it meets its functional requirements. Is this black box or white box testing? 
 
B. Your company develops software under a contract that stipulates that both white box and black box test techniques will be used. What tests are you obliged to execute? 
 
C. A nonprogrammer uses a test tool that automatically instruments the code and then generates tests to ensure that a maximal number of lines of code are executed. The tests are considered to pass as long as the software doesn’t crash or hang. Is this black box or white box testing?  
 
D. What could it mean to perform “gray box” testing?


About the Author
Bret Pettichord is co-author of “Lessons Learned in Software Testing,” which classifies a large number of testing techniques into the Five-Fold Testing System described here. He is a consultant based in Austin, Texas. Contact him at bret@pettichord.com or www.pettichord.com.

Back to Top
 

StickyMinds.com Weekly Column From 11/5/01 

Member Comments
Add Your CommentExpand Comments
 
Comment:    
by Sandeep Desai 7/24/2007

Hi, Can anybody tell me how decision coverage is stronger than statement coverage

 
 
Comment:    
by Rameez ali 12/7/2005

I agree. Defining the boundary is up to you. And when you feel that for applying some sort of technique to overcome a certain problem you crossed the bourdary, thats grey/white box. And the difference between grey and white can be determined on the %age of your knowledge/usage of the implementation details.

 
 
Comment:    
by zameer ahmed 6/17/2005

Sir, Ur Descriptive Explanation Was Good? Actually this Question is not related to this topic. I don't know whether this question is to be ask in this forum or not. but keeping the impoertance of the topic I would like to ask this question. plz Don't say that this is an irrevelant question to this topic. At least send me the site address or any help in form of articles/documentation etc would be appreciated. Now my question is what is "GRAY BOX TESTING"? Thanx in Advance zameer ahmed syed. email : zameer_india@yahoo.com zameer@icoachmath.com

 
 
Comment:    
by Krishna Joshi 5/16/2005

Can you please sugggest a White-Box testing tool that can be used to draw the Basis-Paths from a given source-code segment?

 
 
Comment:    
by Bala singh 3/7/2005

Tell me please whether Unit Testing comes under "Black box testing" OR "White Box testing" ?

 
 
Comment:    
by m m 9/24/2004

1. can you suggest tools for white box testing? 2. What do you mean by statement coverage, decision coverage, path coverage. Can u eplain it in detail? 3. For black box /functional testing which tool do you suggest? Currently we are planning of Winrunner. 4. Also throw some light on client server Application testing. Currently i am working on it.

 
 
Comment:    
by Rosey Baruah 5/6/2003

Bret Pettichord's puzzles are too good. keep publishing. regards, Rosey Baruah software Tester(www.virtuale3d.com) India

 
 
Comment:    
by Karthik Prasad 2/19/2002

This is regarding the response thread that I have read. Traditionally, white box testers look at code and black box testers use the Software Requirement Specification as the bible. But what is more important and what should always be kept in mind that all coding and testing are oriented and carried out to fulfill the requirements of the customer. Even the "white box testers" do black box testing in my opinion as they check for the worthiness of the code written to satisfy user and system requirements. Another thing to be kept in mind in my opinion for black box testing is that the test cases for Black Box Testing should not be limited for...Read On

 
 
Comment:    
by Mary Steinborn 1/26/2002

My answer to your puzzles: A. If the programmer wrote the class or has intimite knowledge of the source code, he is white box testing. If he is testing someone else's work he is black box testing. The testing against functional requirements should have happened at the design level, and the testing of the code (if he wrote it) will most likely validate the design as he understands it. However, by not taking advantage of white box structured techniques for his testing, which independent testers don't have available, his testing is weaker than structured testing should be, yet less objective than black box testing should be. B. White box...Read On

 
 
Comment:    
by Gregory Bowen 11/9/2001

What about defining it from the life cycle? If I am creating a system test plan based on the requirements it is blackbox; if I add test cases after I look at the design those cases are white box. If I am creating a unit test plan based on the design (or program specifications or calling sequence) it is blackbox; if I add test cases after I look at the structure/flow of the code then those cases are white box. Now, if I don't repeat white box unit test cases that I have already identified as black box test cases, and realize that there is also overlap between my black box unit test cases and my white box system test cases, and I remove the...Read On

Author's Response:
11/10/2001    
Let me be perfectly clear. I personally avoid classifying testing as white box or black box. I don't think these terms are useful for either describing or categorizing testing. There is some value to thinking through the concepts. But i hope that doing so will make it plain that what really need is more attention to how we gather information about the software we test, how we decide to test it, and how we collect information about the tests we've run.

 
 
Comment:    
by Danny Faught 11/8/2001

Answer to puzzle E: no. You may get some hints by looking at a test design, but generally you can't tell from a test design whether they are black box, white box, or something in between (the design should explain the techniques that were used, but the tests themselves won't give many clues). In fact, I prefer the terms "black/white box test design" rather than "black/white box testing". This comes from subject 13 of the comp.software.testing FAQ (http://www.faqs.org/faqs/software-eng/testing-faq/), which is the result of a discussion I facilitated on comp.software.testing. For this reason, I don't think it's useful to worry too much...Read On

Author's Response:
11/9/2001    
I agree. Readers might be interested to ready Question 13 on the FAQ, except in this case FAQ stands for "frequently argued questions". Comp.software.testing exploded in debates on the matter until Danny wrote up this FAQ answer. Note that the definition offered in the FAQ focusses on the information used in the design of the test. The problem i have with this definition is that there can be no such thing as "purely" structural testing. I can test to see if the code does what it does, but if i want to know whether it is correct, i have to have some form of requirements.

 
 
Comment:    
by Erik Petersen 11/8/2001

I like to use "behavioural" and "structural" rather than black-box and white-box. It also makes the layers approach more obvious (especially in ambiguous cases say if a developer is integrating components based on the behaviour of their interfaces not the component structure, where he is clearly performing behavioural testing on components, but is still within the "black box" that a system tester sees). If I am at a behavioural level I am testing externals and while I can test many things, I am limited by not having access to internals. That is why it is so important that all the relevant lower layers of structural and behavioural testing...Read On

Author's Response:
11/9/2001    
Pragmatic.

 
 
Comment:    
by john tyson 11/7/2001

It should also be pointed out that black box testing and white box testing complement each other - they are not substitutes. Also, some people view white box testing as "real testing" because they see someone gazing at code, perhaps in a multi-partitioned screen - all looks very impressive. Whereas black box testers are entering scenarios into the app - less glamourous. Clear box testing? Never heard that one, but I have heard of glass box testing.

 
 
Comment:    
by Melissa Mann 11/7/2001

Here's a possible definition of grey box testing: Using code to come up with test cases that will be generated through the user interface. For example, I might look at the database structure of the application for test case ideas: deleting a record that is used by other tables in the application can wreak all kinds of havoc. It's hard to know what the data relationships are without accessing the code or specs, so this isn't necessarily black box testing. On the other hand, if you use the application's GUI to run the tests, it's usually not considered white box testing. Therefore, most people compromise and call it grey box testing. ;-)

 
 
Comment:    
by Bret Pettichord 11/7/2001

I have one more. Puzzle E: If you were reviewing a set of documented tests, would you be able to tell, just by looking at them, whether they were black box or white box tests? What would you look for?

 
 
Comment:    
by Juan Marcos 11/7/2001

I agree with David Holley, testing is testing independently if you know the code (programmer) or you are just a user. I think that the important part is to have a large number of different people and/or techniques probing the same code. Normally in every organization the problem is time, so the tester and developers have to "develop" or use a series of test cases/tools that uncovers as many defects as possible in the little time they have, before the software have to be release. A developers will try to avoid doing black box test, however I worked with some developers that are very good at it, are they white box tester? A good black box...Read On

Author's Response:
11/9/2001    
You say "A good black box tester would avoid to look at the code", but I don't think that it should ever be considered bad for a tester to look at code. A tester should use as much information as is helpful for the job. A lot is made of the "purity" of black box testers that makes no sense to me. It is one thing to say that it's not worth their time, but if they have the time, inclination and ability, go for it!

 
 
Comment:    
by yogita sahoo 11/7/2001

I picked up my definitions for white/black/gray box testing from Cem Kaner's s/w testing book and stayed satisfied with them till I got to read Bret's interpretations. It's really interesting to see that the very basics of our profession can stir up such a strong debate. The article is a very interesing read and so are the thoughtful comments posted on the site.

 
 
Comment:    
by Tanushree Parial 11/7/2001

Another Puzzle: What would you say this team is doing – Black box or White box? The product is a web application, which has various database, XML, and java components that are linked together by some code. The test team gets all these components and they “install” it, meaning they build the database, deploy the Servlets, install the java components and configure all of these to run together. When testing, a lot of times, they are asked to look at the log files generated by each of the components to tell the development team what kind of exception was logged, say, when a web page went blank. Also, a lot of the testing is done by analyzing the...Read On

Author's Response:
11/9/2001    
One of the problems with the terms "white box" and "black box" is that they suggest that they represent purer and therefore better models for what testing should look like. What you describe sounds to me like "smart testing". Because you are not looking at the code, some people say you are not white box testing. But because you are looking at logs, it's not black box. You could call what you do grey-box testing. Indeed this is a better example than some of the other suggestions that people have given here for what grey-box testing is. Better, not from a basis in theory, but because it sounds to me like you have a effective testing approach for finding and isolating bugs.

 
 
Comment:    
by John Daughety 11/6/2001

Reality frequently dictates deviation from theory,and I would imagine that in most cases people are performing some hybrid of white box and black box testing. I think that is why the term "gray box" is used so much. Here's my attempt to apply this article to a real-world situation: Overview: At my current company, there are no requirements and the development group does no testing other than to confirm that the code compiled. In this situation, there is no such thing as black box testing, since there are no requirements that define the expected results. Since the compiler is the only party performing white box testing, reality...Read On

Author's Response:
11/9/2001    
Thanks for sharing your story. Have you read "Testing In the Dark" by Lawrence and Rothman. I think you might be able to find it on this website. It suggests strategies for how to test when you don't have formal requirements documents, similar to what you've already done.

 
 
Comment:    
by Harold LeDrew 11/6/2001

Interesting concepts are discussed in this article. However, it merely provides one of the myriad of possible testing structures. With all due respect to every contributor, just by looking at the spelling and grammar you can tell that both types and perspectives are required to ensure that a product is shipped with a minimum number of flaws. Regardless of how well a product is tested, there is another consideration that is always foremost; marketing usually decides what level of product flaws are permitted. In most test environments, regardless of the types of testing performed, someone usually declares bugs as one of four types: 1. ...Read On

Author's Response:
11/9/2001    
Good answers!

 
 
Comment:    
by Matthias Hamburg 11/6/2001

Just try to think about the basic concepts in testing, and the puzzles will be easy to answer. 1. When testing, you first have to set the scope of testing: system-level, component, unit or whatsoever. These are also commonly called the testing levels. In a small project, you only have one of those; in my actual project, we have eight testing levels. The testing level is usually not directly associated with the notions of white box or black box. Neither is coverage used as a synonym of testing level. 2. Then you have to specify your objects under test: which are the units, components a.s.o. that you are going to test? In many cases,...Read On

Author's Response:
11/7/2001    
I like your answer. You realize that the questions only make sense within a context, and have laid out a reasonable and well-described set of concepts and approaches that allow you to make sense of the puzzles. One thing that becomes particularly apparent is that focus on how a component is tested when testing a larger system is white box, but testing the component in isolation may be black box.

 
 
Comment:    
by Shilpa Roy 11/6/2001

I really liked the article. In order to judge whether my mind has understood as much as i think it has, i have attempted to answer the puzzles. Please correct me wherever iam wrong: A. Since the programmer is checking for requirements it'll be termed as blackbox testing. Again if he goes in depth into the code to verify the requirements it'll be termed as whitebox, but in my experience requirements are always verified externally. So even if it is a programmer checking for requirements he can be assumed to be conducying black box testing. B. All or mostly all the types of testing mentioned in the end of the article will have to be...Read On

Author's Response:
11/6/2001    
The puzzles are really a set of traps. I provided at least five different definitions of white box and black box testing. The answers to the puzzles depend on your definitions. I'm not trying to say that one set of definitions is right or best. For example, Puzzle A is white box if we use a people-based definition. Or if we define the box as the system boundary. On the other hand, if we are focussing on requirements vs code coverage, it is black box. If we are focussing on whether the tester is using knowledge of the code in designing tests, then there is not enough information given to determine the answer. In this case, if the programmer is testing his own code, it is white box; if he is testing someone elses code without reviewing it, it is black box. So the answer all depends on what definitions you are using.

 
 
Comment:    
by Muhammad Abdullah 11/6/2001

An old discussion with a little bit new perspective. As the Tim gave the idea then it would be layering structure and each layer will be with different meanings for different layers.For example: A person who is testing inside the box is performing "white box" who has tested outside the box. But the same person is performing "black box" ffor the person who is testing the components and so on. One idea to know the meaning of these terms, it is vital to know where these terms came from? The term "white box" is perhaps is derived from the Software Engineering term "White box components".Befroe reuse you have to look inside these components...Read On

Author's Response:
11/6/2001    
I agree. When you look at a system as a series of layers, one man's white box can be another man's black box. Thus the important point is to describe the perspectives objectively and not depend too much on terms like white box and black box.

 
 
Comment:    
by George Wilkinson 11/6/2001

Interesting! I believe that it is still worth maintaining the Black box and White Box perspectives as a stake in the ground. Developers/Programmers and pure Testers will always view a software product from a different angle due to psychological reasons, let’s not forget that! Bugs are then detected in a product by examining the object from these different angles, using white and black box techniques. After all, bugs don't arrive by magic, the programmers themselves insert them, and as a result, they can’t always see them.

Author's Response:
11/6/2001    
So George, are you saying that black box and white box are a matter of perspective, technique or both? Can someone with a black box perspective use white box techniques? Can someone with a white box perspective use black box techniques?

 
 
Comment:    
by Tim Van Tongeren 11/5/2001

White versus black is all just a matter of persepctive. One development shop's black box test is another's white box test. Even with the circuit board analogy, there are chips on the board: are those clear too? How about the components on the chips?

 
 
Comment:    
by David Holley 11/5/2001

I like the fact that 'sometimes' is used when identifying white & black box testing. I've been reading an article by Boris Beizer that challenges wether or not the black/white box concept is valid in today's environment. I'd elaborate more on it, but I'm still digesting it.

Author's Response:
11/6/2001    
Boris Beizer is well known for reasonable critique of the black box/white box distinction. After arguing that the terms only lead to confusion, he published a book under the title "Black Box Testing". In researching this column, i read a number of testing books, each of which seemed have somewhat different definitions of what black box and white box meant. I thought Rex Black's discussion in "Managing the Testing Process" was particularly pragmatic.

 
Back to Top



 
Ads By Google
What's This?
 
 



Home   |   Resources   |   Topics   |   Community   |   PowerPass



© 2010 StickyMinds.com. All rights reserved.
StickyMinds.com is a division of Software Quality Engineering.
Privacy Policy    Terms & Conditions    Link to StickyMinds.com    Feedback


ThoughtWorks




STAREAST 


Better Software Conference