• 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

Good JUnit Tutorial?

 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are there any good JUnit tutorials on the Web suitable for a beginner? What's the recommended "beginners" book?
Thanks
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://quilt.sourceforge.net/tutorials/junit.html
Good book
JUnit in Action
You may win the book this week. Good luck!
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pradeep, I get a 404 error on that link, as well as the tutorials directory.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The link should be valid. It seems that quilt.sourceforge.net is down.
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "Unit Testing in Java: How Tests Drive the Code" is a good book to beginning unit testing.
 
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
Tom,
While it's not a tutorial, the bowling example provides a nice overview. It follows two programmers through the exercise of using Junit to write a program using test driven development.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just my two cents, but I would be careful about confusing test driven development (TDD, aka test-first design), a development methodology, with JUnit, a framework. Creating good unit tests does not require that TDD principles be used.
A couple of JUnit tutorials worth checking out are JUnitTest Infected: Programmers Love Writing Tests and JUnit: A Starter Guide.
The article Jeanne linked to is an excellent overview of test-driven development and pair programming. It's definitely worth a read. For a detailed look at TDD, you may want to check out Evolution of Test and Code Via Test-First Design (pdf).
 
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
Jason,
I agree about not confusing the two. Some (but not all) of the junit tutorials include TDD. And even more of the articles on TDD include pair programming.
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Menard:
Just my two cents, but I would be careful about confusing test driven development (TDD, aka test-first design), a development methodology, with JUnit, a framework. Creating good unit tests does not require that TDD principles be used.


That's the problem when you know just enough to cause trouble. I had thought they were mutual predicates. Now it looks like I have to learn TDD just so I know when and when not to apply it.
Thanks for all the responses so far. I'll be palying with some of the tutorials and walk-throughs this weekend.
Tom
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the learning curve for Junit?
 
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 Pradeep Bhat:
What is the learning curve for Junit?


As I answered to someone earlier, it's very easy to get started with JUnit. Reading this article and trying out the examples yourself is a good start and doesn't take long.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Menard:
Creating good unit tests does not require that TDD principles be used.


Agreed. TDD is more about creating a good design of the production code than about testing. High test coverage is more of a side effect of TDD.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For what it's worth - I used the tutorials they point you to when you download JUnit and I got it working reasonbly well.
I think the biggest challenge was figuring out how to set-up the part that ran all my tests and how to use it from the Swing GUI.
Now I use it from Ant and that took a little figuring out too.
If you are using Ant, I'd recommend Erik Hatcher and Steve Loughran's Java Development with Ant - also published by Manning. There are examples on how to set-up Ant with JUnit and how to run the reports that the Ant task can generate.
Here's some more JUnit resources:
Scott Davis, the Ex-President of our local Java User Group did a talk on JUnit for our Basic Concepts.
Here's his ZIP file: http://denverjug.org/bc/junit.zip.
Sort of interesting that Patrick Linskey was the featured speaker and he's co-author of Bitter EJB. The other JUnit resource I'm going to point to is Mike Clark, another co-author of Bitter EJB and author of JUnitPerf.
He spoke to our JUG on Bitter EJB but he also gave a great talk on JUnit to the XPDenver user group.
Agile Design and Testing With JUnit was the name of the talk and it was sponsored by Net Objectives.
Here's a link that describes Mike's talk (which was terrific by the way) and here's a link to his notes. He also does Test Driven Design and I believe he talked about that but as others have mentioned, you do not have to do TDD to start using JUnit.
Hope this helped -
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Greg. Ant is also on my to-learn list.
 
Ranch Hand
Posts: 182
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joey Sanchez wrote:
I think it is a good JUnit tutorial

http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBUQFjAA&url=http%3A%2F%2Fwww.vogella.de%2Farticles%2FJUnit%2Farticle.html&rct=j&q=junit%20tutorial&ei=vbBkTtigNYqGhQeL8cGpCg&usg=AFQjCNHqX26U3fC3isS-kpoFaYdl3kW08Q&sig2=CJI-nJqiXINXc_HRATQ2Zg&cad=rja



That is vogella's tutorial. It is not good. It only teaches you to copy paste code. It does not explain why Junit is used and how does it help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic