Demo
Step 1 | Step 2 | Step 3 | Step 4 | Step 5 | Step 6
Step 1 - Installation and Setup
Make sure tools.jar (part of JDK), junit.jar, and junitdoclet.jar are in the class path. Doublecheck the directories in the build.xml. The junit task in ANT is optional, but we need it to execute the demo. Please make the optional.jar available to ANT (e.g. put it to %ANT_HOME%/lib). It's worth it. Define an ANT target for JUnitDoclet in the build.xml and assign the package to be processed and the name of the main test (the TestSuite covering the processed package). Note: By default, the name of a TestSuite contains the name of the parent package (package Fasten your seat belt (but don't put the tables in front of you to their upright position ;-). |
|
Step 2 - Application Classes
If you are here for the first time, just create the application classes (that you know of already), define their methods and make them compilable. You can do more, but if you prefer "test first" you don't do that now. ("test first" means, you synchronize with your tests first, implement them, see them failing... not before then you start to implement the application classes and make them pass the tests.) For now let's compile the application classes. If you are here for the second time, chances are some tests have failed. Implement and run the tests again. If you need to create a new class or a public method, don't forget to synchronize your tests (see above). |
|
Step 3 - Compiled Application Classes
The application classes are compilable. This is necessary for javadoc to be able to parse the source code of them. |
|
Step 4 - Generating Tests With JUnitDoclet
Javadoc is parsing the source code of the application classes. From the collected information, JUnitDoclet writes TestCases and TestSuites preferably to a different directory tree (here: junit/).
Not all the tests can be compiled directly after they have been generated for the first time. But most of them will. The compiler will help you with the others by pointing to code where:
There is no wizard but you to fix these problems. But don't be sad, it is easy to solve these problems. Did you ever try to outsmart a wizard that did not produce what you wanted? And after all, the fix remains even during re-generation because it is inside a marker pair. |
|
Step 5 - Compiled Tests and Application Classes
If you've reached this state without any warning, you managed to synchronize tests and application classes. Go to the next step to perform the tests. |
|
Step 6 - Running the Tests
Do your tests pass? You will see the result in the testresult.txt (but you can direct it to the console as well; see build.xml) If the tests fail, go back to step 2. Still here? Congratulation. It's time to implement the next feature. Go to step 2 for the first time again. ;-) |
|