wood burning stoves 2.0*
The moose likes Agile and Other Processes and the fly likes Blackbox and Whitebox testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Agile and Other Processes
Bookmark "Blackbox and Whitebox testing" Watch "Blackbox and Whitebox testing" New topic
Author

Blackbox and Whitebox testing

Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
Can someone elaborate on the above testing mechanisms?
Thanks in advance,
Sandeep

<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
http://www.faqs.org/faqs/software-eng/testing-faq/section-13.html
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Thank you Ersin
Went through the FAQ link you had sent.Could you explain with a specific example as to what is the difference between two types of testing?
I have heard of terms like Unit Testing and System Integration testing.Is the "Box" Testing applicable for both these forms?
Regards,
Sandeep
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
Sorry for the delayed answer .( Actually I don't have the answer since I am trying to learn these topics too )
One of my friend does this for living I hope I can get a hold of her , see what she thinks?
I will post any answer that I might get.
ersin
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Black box testing is a commonly used term in engineering (it didn't start in software). Basically, imagine you have black box. You can't see inside it to see how it works. You can only give it inputs, and see what comes out.
I'm sure you've seen things like this before. Certainly in math, I can give you a function y=f(x), and if I give you enough data points, you can figur eout the curve. The way to get data points is by saying, "Mark, suppose x=3...." Then I'd reply, "then y=7." You gave an input, and saw the output, but didn't see how it worked.
You see this often in EE, when you have some circuit, but don't knwo what it is. Since the ciruit is ultimately a bunch of gates, you can exhaustively go through the inputs to define the output.
If you remember how Rutherford discovered the nucleus of the atom, it was the same thing. Back then, we couldn't "see" something that small. So he fired alpha particles at the atom. Most passed straight through. Those which went near the center of the atom got deflected, and he surmised that there most be something in the center of the atom with a positive charge. The atom was the black box, the alpha particles where in the input, and the output was the angle of deflection.

White box testing, sometimes called glass box testing, is the opposite. You can "see" into the function and see how it works. Programs which do "code analysis" for correctness, dead paths, infinite loops, adherence to coding standards, etc do this type of testing.
Unit testing is black box. Most regression testing is base don black box. Last month foo(3,7) returned a value of 12. If I run the test again, will I get the same answer? If not, maybe someone introduced a bug (that, or the code was wrong to begin with, and someone fixed it).
Does that help explain it?

--Mark
Allan Moster
Ranch Hand

Joined: Sep 14, 2001
Posts: 153
Originally posted by Mark Herschberg:
Unit testing is black box. Most regression testing is base don black box. Last month foo(3,7) returned a value of 12. If I run the test again, will I get the same answer? If not, maybe someone introduced a bug (that, or the code was wrong to begin with, and someone fixed it).
--Mark

Huh? You mean I can't examine the application's code, or create and execute tests which is designed to determine if any parts of the application will crash when the application is used in expected or unexpected ways (White-box)?
IMHO, unit test can be black-box or white-box or both!
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Originally posted by Allan Moster:
Huh? You mean I can't examine the application's code, or create and execute tests which is designed to determine if any parts of the application will crash when the application is used in expected or unexpected ways (White-box)?
IMHO, unit test can be black-box or white-box or both!


No, you can do that. If you do it by algorithmic inspection, I would call that white-box. If you do it by testing combinations of inputs, I would call it blackbox. But it's just semantics.
I suppose unit testing is relative--what is a unit? Methods are ver well defined units. You could, however, argue that a given code block is a unit; and if you can test that code block (relatively) independently, then I suppose you could call the unit testing.
--Mark
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Thanks very much Mark for your explanation.Thanks you ersin and Allan to contribute to my post.
From what I have understood, Unit testing from the functional view-point would be a blackbox testing while from the code inspection view-point would be a whitebox testing.
This means if you have coded a small program and prepare a test case which says,if you input A to the program you expect B as the output, then it is black box testing.Here you are testing the functionality of the program.
On the other hand, if we consider the intermediate values that are generated while going to the algorithm (ofcourse to check if it is the way we desire!), it becomes a transparent - white box testing
If this is correct, I would like to ask "What do we prefer for Unit testing?".Also, "How does one proceed to test the code (Let's assume that we are not using any testing tools!)"
Thanks and Regards,
Sandeep
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Originally posted by Desai Sandeep:
From what I have understood, Unit testing from the functional view-point would be a blackbox testing while from the code inspection view-point would be a whitebox testing.

Exactly! It wouldn't surprise me if there's some type of hybrid test, which involves some of both, although I've yet to see any. Obviously, you can do both.

If this is correct, I would like to ask "What do we prefer for Unit testing?".Also, "How does one proceed to test the code (Let's assume that we are not using any testing tools!)"

I don't understand what you mean by what "do we prefer?" I'll answer the second question and see if that helps with the first. Well, without any tools at all, you've got just two options: code reviews (whitebox), and trial runs (black box). I assume you mean testing without commercial test products. In that case, I recommend checking out JUnit at http://www.junit.org/ This is a decent tool for writing Java unit tests.
One thing to keep in mind, unit testing isn't great for everything. UI, network communications, and complex systems with a lot of setup overhead aren't tested well in unit testing. For that you generally need end-to-end testing.
--Mark
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Originally posted by Mark Herschberg:
[..]I don't understand what you mean by what "do we prefer?" [..]

Am sorry for being unclear with the the question I raised.With your latest post, you almost answered the query that I had in mind.You mentioned one may select white-box or black-box or a combination of both.
Assuming that I follow a very primitive method of testing, i.e developing test cases, I ensure that my test cases are developed from both functional view-point (black-box) as well as code inspection view-point(white-box).
My query was whether there is a preference to white-box or black-box testing while developing test cases for Unit Testing.As per my knowledge it depends on what stage of testing you are in.Will you prepare test cases from a functional view-point first and then from code inspection view-point or vice-versa? Please do let me know what and why you prefer?I will surely visit junit.org and raise any questions that I have.
In your recent post you introduced one more jargon called "end-to-end testing".How is this different from Unit testing?Is this an alias for System Integration testing?
Looking forward for your views and comments.
Regards,
Sandeep
[This message has been edited by Desai Sandeep (edited November 11, 2001).]
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Yes, end-to-end testing is often synomomous with system testing or system integration testing. Basically starting with input at one end, and making sure you get the right results out at the other end.
Generally unit testing is added in during development--as I create new methods and classes, I'll create tests for them. Functional testing usually derives from the requirements. These tests often can best be performed towards the latter stages of development, when the system starts to work as whole, and not as hundreds of independent units.
Does that help?
--Mark
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
Concerning white-box (invasive) testing, you can also refer to
a Dr Dobb's article .
W.
[This message has been edited by Wilfried LAURENT (edited November 20, 2001).]
 
Don't get me started about those stupid light bulbs.
 
subject: Blackbox and Whitebox testing
 
Similar Threads
XPath translate function
program design
test
return DataInfo[]
This is just a test....