• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Author
Posts: 55
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic