File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Good JUnit Tutorial?

 
Tom Blough
Ranch Hand
Posts: 263
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep, I get a 404 error on that link, as well as the tutorials directory.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The link should be valid. It seems that quilt.sourceforge.net is down.
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "Unit Testing in Java: How Tests Drive the Code" is a good book to beginning unit testing.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Jason Menard
Sheriff
Posts: 6450
  • 0
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the learning curve for Junit?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Greg Ostravich
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Greg. Ant is also on my to-learn list.
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic