Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Andy Hunt
Author
Ranch Hand
Posts: 55
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Lasse: by the way, i'm female
*slaps forehead* Doh!
Of course you are. Sorry about that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic