Powered by | Extend CodeGuide featuresMichel CASABIANCA - casa@sweetohm.netThis article presents CodeGuide extensions to launch JUnit tests, open a BeanShell console and Ant builds within this IDE.
The Code Guide IDECodeGuide (which evaluation version can be downloaded on Omnicore's web site) is, in my humble opinion, the most efficient Java developement environment. It includes the most useful features of better Java tools (such as on the fly syntax checks, efficient code completion and a fast debugger), but without unnecessary fat, with makes it very fast (some of my colleagues though it was a native tool :o)
Figure 1: CodeGuide IDE It is possible to extend CodeGuide features using external tools. CVS is integrated this way in the IDE for instance. In this article, I show how you can integrate JUnit, Beanshell and Ant as external tools. JUnit integrationJUnit is a well known unit test framework. Using this tool, developing and running these tests is a piece of cake. A dedicated Ant task may also generate test reports. JUnit is an Open Source tool that you can download for free at http://www.junit.org. I have written an introduction to JUnit, in the May/June issue of Oracle Magazine. The goal of this integration is to run a unit test, within CodeGuide, with a single click and see the result in the tools console. Open the Tools/Configure Tools... menu. The following dialog box will open:
Figure 2: JUnit integration in CodeGuide Click on the New button and fill fields with the following values:
Close the tool configuration dialog box clicking the OK button. You can now launch a test with a right click on a Java source file (in the project pane or in the editor itself) and selecting the JUnit item in the menu.
Figure 3: Run a JUnit test The test result appears in the tools console:
Figure 4: JUnit test result Note that you must click on the Build Project button in the tool bar (or press key F9) before running a test, in order to build the corresponding class file. Furthermore, it is possible to launch a unit test using a main() method and changing the starting point of the project, but it is more convenient using the JUnit launcher (especially for web application where starting point is a bit weird). Beanshell integrationBeanshell is a Java interpreter (with some scripting features). You can download it for free at http://www.beanshell.org. Integration in an IDE is useful when developing scripts or to test code fragments using the Beanshell interpreter as a scrap book. Thus, the goal of this integration is to run scripts from the editor and launch a Beanshell console. Beanshell interpreterTo integrate the script interpreter, open the tool configuration dialog box, click on the New button and fill the fields with the following values:
We can now run the interpreter with a single right click on a script source and see the output in the Beanshell console.
Figure 5: Beanshell interpreter Beanshell consoleTo run the interpreter in a console, open the tool configuration dialog box, click on the New button, and fill the fields with the following values:
To open the Beanshell console, select the Tools/Beanshell Console item of the menu, the following window appears:
Figure 6: Beanshell console We can evaluate Java expressions and see the result in the console. This is an handy way to quickly test a piece of code and paste it in the editor. Ant integrationAnt is a build tool (that may be compared to make) dedicated to build Java projects. I have written a series of articles on Ant in the November/December and January/February issues of Oracle Magazine. Ant is integrated to CodeGuide out of the box, but if you chose ant builds, on the fly code generation is not running, which is a key feature of CodeGuide. The goal of this integration is to launch an Ant build from within the interface using on the fly code compilation. Open the tool configuration dialog box and fill the fields as following:
You can now open a file context menu (with a right click) and launch the build choosing the Ant item. I genrally choose Use internal incremental compiler in my projects preferences and launch Ant builds when necessary (to generate a jar file for instance).
Figure 7: Ant console displaying a build result ConclusionEven if CodeGuide's customization can't compete with Emacs, it is very useful to integrate in this IDE your favorite tools. We could wonder what is missing to CodeGuide (when you'll have tested classes Hot Swap or Tomcat integration). Maybe a plugin API so that any developer could send Omnicore their own extensions. Please Omnicore developers, think about that! Thanks Frédéric for his corrections! Last update: 2004-01-06 |