< Day Day Up > |
IntroductionTesting and debugging code is a fact of life for Java developers, and this chapter focuses on the testing and debugging facilities that come with Eclipse. Often, you can test your code using the JUnit package that comes with Eclipse, and you can debug it using the built-in debugger. We'll look at both facilities in this chapter. JUnit is an open source testing framework (for more information on the Open Source Initiative, visit http://www.opensource.org). You use it to test the results of JUnit-based classes that call methods in your code. An Eclipse plug-in facilitates the process of running JUnit tests. Using JUnit, you can create a standard set of tests and distribute them to everyone working on your code; if someone edits your code, all that person needs to do is to run the tests with a few mouse clicks to make sure he didn't break anything. JUnit works by calling your code using a set of assertion methods that test the return values from your code. Here are the JUnit tests:
When you run a JUnit application using the JUnit plug-in in Eclipse, it opens its own view to give you immediate feedback on which tests have passed and which have failed. |
< Day Day Up > |