Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JUnit in Action questions

 
Greg Ostravich
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Vincent Massol
Author
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greg Ostravich
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wanted to thank you for answering my questions.
Greg
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greg Ostravich
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
bengt hammarlund
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic