Testing your privates
How do you test private methods when doing test driven development?
Some people have developed interesting techniques designed to expose your private methods to their test framework without exposing them to the outside world. If you think of TDD as being mainly about designing the public interface and making certain that everything you call through the public interface works properly, then you do not care about being able to call the private methods directly. If you think about unit testing in its pre-eXtreme Programming sense, then you might want to test every private method because it is another unit that should be exercised.
Also in Java Today, Bill Venners considers your options in Testing Private Methods with JUnit and SuiteRunner. Based on his experience writing SuiteRunner he writes that your alternatives are "Don't test private methods. Give the methods package access. Use a nested test class. [or]Use reflection."
Unit testing is not the same as debugging. For the most part, agile folks think unit testing keeps them out of the debugger. Another type of tool for discovering bugs is a static analysis tool. Chris Grindstaff has part one of an article on FindBugs. You can use it to examine "your class or JAR files looking for potential problems by matching your bytecodes against a list of bug patterns. With static analysis tools, you can analyze software without actually running the program. Instead the form or structure of the class files are analyzed to determine the program's intent, often using the Visitor pattern." The article also urges you to consider what you are going to do with the results.
Bob Lee expands on the example from the pico container Two-minute tutorial in
today's Weblogs. Bob recounts a discussion he had with Cedric about Cedric's " 'useless methods' blog and the benefits of getter-based dependency injection over setter or constructor-based injection (a la pico container and Spring). Cedric compares CMP entity beans with theoretical getter-based containers which extend classes at runtime and override getter methods to return injected dependencies. The overridden getters may be bean-style (for easier testing) or abstract (for a cleaner, field free implementation). Such a framework would not require classes to declare setter methods, constructors or fields. Getter injection better enables the container to lazy load dependencies and simplifies injecting different dependencies of the same type."
John Reynolds continues his travel report with BEA eWorld: Day Three. John reports on Adam Bosworth's demo of his answer to "s new UI challenges due to the problem of unreliable connectivity (occasionally connected devices). The answer will be intelligent Browser caching and intelligent UI servers." John also heard an honest answer to his question "'Why will Services be reused more then objects were?'. The answer they returned was that services won't be reused unless governence is established within IT to make sure that they are reused. Once again, the technology is only part of the solution."
In today's Projects and Communities ,
the JXTA community is playing with a Paper Airplane... a Mozilla plug-in that allows browser users to form a collaborative community by starting up a JXTA peer network between users.
Help Swing Easy amass Swing know-how, tricks, and best practices in one place. This Java Desktop Community project is gathering information that is currently scattered about the internet and the developer community
Forums Athomas Goldberg launches the new discussion on The 2004 Java Technology Game Development Contest. In this forum he hopes to "address any burning questions you have about the contest: the rules, the prizes, the judging criteria, etc, In addition, we'll try to spark some lively conversations about your hopes and expectations for the future of Java as a platform for game development. So if you have any questions or comments, or any contest-related issues you'd like to discuss, we invite you to post to the forum and get the ball rolling"
Mark Swanson writes about Native widgets saying "if 1.5 has a look and feel that you create by just giving it an XML file and images then you could simply just render and cache the images on the native platform. Done."
In today's java.net News Headlines
- Java Web Services Developer Pack 1.4
- Early Review Draft JSR 225 - XQuery API for Java
- JasperAssistant 1.1.4
- SQL4X Manager J 2.8
- JFlashPlayer 1.2
- Application Privacy Monitoring for JDBC Initial Release
- Mac OS X 10.3.4
Registered users can submit news items for the
href="http://today.java.net/today/news/">java.net News Page using
our news submission
form. All submissions go through an editorial review by news director
Steve Mallet before being posted to the site. You can also subscribe to
News RSS feed.
Current and upcoming
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e"> events submission
form. All submissions go through an editorial review before being
posted to the site.
Archives and Subscriptions: This blog is delivered weekdays as the
Today RSS feed. All java.net members can subscribe to the email
updates for the site at the href="https://java-net.dev.java.net/servlets/ProjectMailingListList">
java-net Mailing Lists page. You must be logged in to subscribe
to the javanet_Daily and javanet_Weekly lists. Also, once this page
is no longer featured as the front page of
java.net it will be archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.