JUnit JUnit is an (Web hosting resellers) Open Source tool that
JUnit JUnit is an Open Source tool that allows you to create and execute test suites quickly and systematically. The people behind JUnit are Kent Beck and Erich Gamma. Since Erich Gamma is also significantly involved in the development of Eclipse, it is no surprise that JUnit is contained in the Eclipse SDK distribution. Detailed information is available at www.junit.org or in Professional Java Tools for Extreme Programming by Richard Hightower, et al. Test tools such as JUnit are used to test program modules repeatedly, especially after changes have been applied to a module. Using such automated test tools allows you to test frequently and after each small incremental development step, following the XP motto: Code a little, test a little. Of course, the quality of the test results stands or falls with the quality of the test suite. A good test suite should cover the whole functional range of a program module. This is, however, easier said than done! Setting Up JUnit To be able to work with JUnit, the JUnit JAR file is required in the build path of your project. You could manually add junit.jar as an external JAR file to DukeSpeaks project, as described in the Project Properties section in Chapter 4. You can find junit.jar under eclipsepluginsorg .junit_3.8.1. However, this is not really required, since Eclipse will do this for you when you create your first test case. In the DukeSpeaks project you can now create a test case class (a subclass of the JUnit TestCase class), which you can call PlayerTest. You can create such a class manually, or you can use the JUnit Wizard (Figure 6.4) in which case you proceed as follows: 1. Invoke the wizard via the File > New > Other > Java > JUnit > Test Case function. 2. In the first page of the wizard, press the Browse button at the Class to Test field and select the class that you want to test (Player). 3. To name the test, enter PlayerTest in the Name field. 4. In the Package field select a target package (within your project) for the new TestCase class. 5. Additional options allow you to generate a main() method, a setUp() method, a tearDown() method, and a constructor for the new test case. On the next page of the wizard select which of the test class test methods are to be generated (Figure 6.5). Here I have selected only two methods. Normally you would first select all methods and then explicitly deselect all the methods that you don t want to test. Optionally, you can decorate all generated methods with the modifier final. TODO comments can be generated into the method stubs. 120 Chapter 6
We are the the largest streaming host company, and we provide professional audio & video web hosting streaming using Real Networks, QuickTime, Flash and Windows Media.We strongly recommend you to visit and check web hosting streaming services.