Junit in action, nice name but Jess in action sound more savvy :roll: just an opinion. Anyway, I have yet to embark on any "testing suite". I've heard of Junit but not sure what it is. I use an idea that I picked up from Allen Holub in his book Taming Java Threads. The idea is simple; create a static inner class for every class that you wanna test. For testing, you just invoke the Test as in:
Finally, for deployment, you simply remove all Test classes. My questions to the author:
What's the advantage of Junit over the aforementioned?
Is it possible to incorporate this method with Junit?
What's a "testing framework" anyway?
Finally, is it worth the effort to learn Junit or getting the book? Thanks, Leslie
benefits of junit: 1) to reiterate, junit has a framework that uses reflection to automatically gather up and run many unit tests 2) junit has solid ant support, making automatin even easier 3) junit's ant support give you the ability to create a swanky-looking html report that shows all the results of the unit test runs. we use this on our continuous build machine
I would just like to point out that the static inner test class idea and JUnit are not mutually exclusive, and in fact, we sometimes use static inner test classes and JUnit together. If you write your JUnit TestCases as inner classes, then they have access to the private data in a class, making it easier to test. As a general rule, it's better to test using only the public interface of a class, if you can; but in cases where that would uglify things significantly, the static inner TestCase is your best friend.