my dog learned polymorphism*
The moose likes Testing and the fly likes JUnit in Action questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit in Action questions" Watch "JUnit in Action questions" New topic
Author

JUnit in Action questions

Greg Ostravich
Ranch Hand

Joined: Jul 11, 2002
Posts: 112
There are some idiosyncracies that are not intuitively obvious to the most casual observer when mixing Ant and JUnit and I wondered if you cover them in your book.
For example - when I added JUnit to my Ant build it broke my JUnit so when I threw an exception on failed assertions it no longer told me what line number my error was on. I couldn't find an answer until I posted the question on JGuru. Erik Hatcher (committer on Ant and co-author of Java Development with Ant - another great Manning publication) explained that you need to turn the debug switch on (javac -debug=true) for your compiles within Ant. By default, command-line compiles have debug on, but from within Ant they are not.
Do you cover what to test and what not? I've only used JUnit on one project so far and I think I got carried away. I tested more than I probably needed to. I even wrote methods to over ride the equals functions for my data structures so I could use that to test for equality with those structures in my unit tests. I tested object construction too. How much is too much?
Do you talk about how to structure your directories for your code source and your unit tests?
Do you talk about test driven development and give examples of that?
Do you talk about both the Swing GUI for JUnit and the textual results you can generate?
Do you talk about wrappers like JUnitPerf to check performance? If you do, do you give source code examples?
Do you talk about whether we should use the built-in assert that was added to the latest JDK or just keep using JUnit's assertions?
Is there another framework besides JUnit that uses the built-in assertions?
Thanks for being here to answer questions.
I bought Erik's Ant book and it sounds like this one is great too.
---
Note to the moderators - I think it's lame that to increase my chances of winning this book I would have to post each of the questions above in separate threads so I have more than one post. It'd be great for the giveaways if everybody that had a post on the topic was given one entry instead of forcing those that want to win to post multiple times to have a decent chance of winning.
[ November 04, 2003: Message edited by: Greg Ostravich ]

Greg Ostravich - SCPJ2
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by Greg Ostravich:
There are some idiosyncracies that are not intuitively obvious to the most casual observer when mixing Ant and JUnit and I wondered if you cover them in your book.
For example - when I added JUnit to my Ant build it broke my JUnit so when I threw an exception on failed assertions it no longer told me what line number my error was on. I couldn't find an answer until I posted the question on JGuru. Erik Hatcher (committer on Ant and co-author of Java Development with Ant - another great Manning publication) explained that you need to turn the debug switch on (javac -debug=true) for your compiles within Ant. By default, command-line compiles have debug on, but from within Ant they are not.
Do you cover what to test and what not? I've only used JUnit on one project so far and I think I got carried away. I tested more than I probably needed to. I even wrote methods to over ride the equals functions for my data structures so I could use that to test for equality with those structures in my unit tests. I tested object construction too. How much is too much?

Yes, this is covered but not in a single chapter that would discuss the rethoric of it. It is covered a little in all chapters, by showing different ways of performing unit tests with different frameworks. It shows the pros and cons. I've personally never found a time when I was doing too many tests. What I did find in some cases is that I was not writing tests the correct way and it was taking me too long or the tests were too fragile. In both cases, the solution was not to test less but rather to test differently with a better strategy/tools.
Do you talk about how to structure your directories for your code source and your unit tests?

Yes. Actually it goes quite far in showing directory structure best practices for lots of projec types: web app project, ejb project, simple project, etc. It shows this when using Ant and Maven.
Do you talk about test driven development and give examples of that?

Yes. There's a section of a chapter explaining the theory and one chapter practicing it. I've tried to stay away from doing TDD in all chapters as you can use all the techniques/tools explained with or without TDD. However, I still wanted to show it in practice. To be honest, if you want to learn the TDD "theory", I would recommend Kent Beck's book. This book is more on the practical side (how to do stuff).
Do you talk about both the Swing GUI for JUnit and the textual results you can generate?

No. The book doesn't cover Swing unit testing.
Do you talk about wrappers like JUnitPerf to check performance? If you do, do you give source code examples?

Very briefly only. Performance testing is not covered in the book.
Do you talk about whether we should use the built-in assert that was added to the latest JDK or just keep using JUnit's assertions?
Is there another framework besides JUnit that uses the built-in assertions?

They're for different purpose really.
Thanks for being here to answer questions.
I bought Erik's Ant book and it sounds like this one is great too.

Thanks. I hope you'll like it!
-Vincent


-Vincent<br /><a href="http://www.manning.com/massol" target="_blank" rel="nofollow">JUnit in Action</a> author
Greg Ostravich
Ranch Hand

Joined: Jul 11, 2002
Posts: 112
I just wanted to thank you for answering my questions.
Greg
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Greg, your wish regarding the book promotion rules has been posted to the moderators' forum. However, I have to say it is unlikely that the rules will change that much.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Greg Ostravich
Ranch Hand

Joined: Jul 11, 2002
Posts: 112
Lasse -
Thanks for posting my comment to the moderator's group.
I thought that it would be better the way I suggested so people didn't have to post 4 different one-liner threads just to have a good chance to win the book. If you look in the group list today you'll see a few one-liners from the same people and it's unfortunate because it fills the group with lots more questions that are probably harder for the author of the book giveaway to track and make sure they reply.
Thanks again -
Greg
bengt hammarlund
Ranch Hand

Joined: Oct 17, 2003
Posts: 78
One question I have is:
do this book cover any EJB JUnit testing? I already did it using mock objects, but it's really not that easy.


<b><i>Bengt Hammarlund</i><br />� Sun Certified Java Programmer</b>
bengt hammarlund
Ranch Hand

Joined: Oct 17, 2003
Posts: 78
Another question:
I know that are another testing tools based on JUnit, does this book cover stuff like HTTPUnit and others that are useful on enterprise Java system testing, and are based on JUnit?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

Lasse,
Is the rule that you have to post to be entered or you have to start a thread? I thought all posts (even those within existing threads was counted), but Greg's question confused me. Or did Greg mean that he asked several questions within the same post.
Thanks.


[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
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Jeanne Boyarsky:
Is the rule that you have to post to be entered or you have to start a thread? I thought all posts (even those within existing threads was counted), but Greg's question confused me. Or did Greg mean that he asked several questions within the same post.

You can read the rules here. Both a thread-starter and replies are eligible as long as they're on-topic. And yes, Greg meant that he could've asked all those questions in separate posts, which would give him more of a chance to win.
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by bengt hammarlund:
One question I have is:
do this book cover any EJB JUnit testing? I already did it using mock objects, but it's really not that easy.

Yes! Chapter 12 is all about EJB unit testing using different techniques (mock objects at different levels, pure JUnit, Cactus). See the TOC on http://www.manning.com/massol. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit in Action questions