Showing posts from May, 2011

Creating JUnit Test Case, Rapidly in Eclipse

Implementing JUnit test case for java class is much more easier than ever with Eclipse IDE. The framework of JUnit test case is generated by following some simple menus. I used the case of Java Puzzlers ' second chapter's first puzzle for demonstration. I implement an Oddity class has three methods (isOdd, isOdd2, isOdd3) each of which takes an integer as parameter and returns true if the integer parameter is odd. This puzzle is examining a trap can fail any java developer from novice to professional, since method is so simple and generally, anybody doesn't focus on simple things while dealing with problems. For creating a JUnit Test Case for Oddity class methods, first right click on Odditiy class on package view select New > " JUnit Test Case " as shown below. On the new menu, the test case name is automatically filled with appending original class name and " Test " word. Only change the " source folder " (generally test) to where