aspose file tools*
The moose likes Testing and the fly likes What Is Unit Testing -- and what it is NOT. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "What Is Unit Testing -- and what it is NOT." Watch "What Is Unit Testing -- and what it is NOT." New topic
Author

What Is Unit Testing -- and what it is NOT.

Andy Hunt
Author
Ranch Hand

Joined: May 01, 2001
Posts: 54
Hi folks,
there seems to be some persistent confusion about what we mean when we talk about unit testing, which Dave and I have addressed in some of the posts below, but I thought I should try to clarify the issue.
There are lots of different kinds of testing that can and should be
performed on a software project. Some of this testing requires
extensive involvement from the end users; other forms may require
teams of dedicated Quality Assurance personnel or other expensive
resources.
None of that is unit testing.
A unit test is a piece of code that exercises a very small, specific area of functionality of the code being tested. Unit tests are performed to prove that a piece of code does what you think it should do.
It may or may not be the RIGHT thing to do according to the customer or end-user: that's what acceptance testing is for. We're not really concerned with formal validation and verification or correctness just yet. We're really not even interested in performance testing at this point. All we want to do is prove that code does what we intended, and so we want to test very
small, very isolated pieces of functionality. By building up confidence that the individual pieces work as expected, we can then proceed to assemble and test working systems.
After all, if we aren't sure the code is doing what WE think it is, then any
other forms of testing are just be a waste of time.

Finally, as a courtesy to all you loyal Java Ranch readers, here's a link to the online store that will give you a 20% discount on the Starter Kit books and PDFs:
http://pragmaticprogrammer.com/shopsite_sc/shopping_cart/order.cgi?storeid=*167d03fb829b81b917e3a91f00&rec=23&cpid=1077129594&function=add
Or, just order using our normal shopping cart and enter the coupon code JR914XL when asked.
thanks, and enjoy!


/\ndy Hunt<br /> <a href="http://www.PragmaticProgrammer.com" target="_blank" rel="nofollow">www.PragmaticProgrammer.com</a>
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

None of that is unit testing.

I agree. I think some of us introduce confusion because junit can be used for other things. We use junit to test JDBC - integration tests.
I guess another thing is that unit testing is not the same as junit.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Jeanne Boyarsky:

I guess another thing is that unit testing is not the same as junit.

Of course, JUnit is a testing tool to do the unit testing... So I'm not sure about the reason why you are comparing the type of the testing and the tool that can be used to do that testing...
Correct me, if I got confused with meaning of your words...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Ko Ko Naing:
Of course, JUnit is a testing tool to do the unit testing... So I'm not sure about the reason why you are comparing the type of the testing and the tool that can be used to do that testing...
He's not. He apparently referred to the quite common association Java developers new to unit testing have that "unit testing" equals "JUnit tests".


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

Lasse is right. There is a lot of confusion about the difference in general. Since Andy started a thread on what unit testing isn't, I figured I would include that.
Lasse: by the way, i'm female
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Jeanne Boyarsky:
Lasse: by the way, i'm female
*slaps forehead* Doh!
Of course you are. Sorry about that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What Is Unit Testing -- and what it is NOT.