Friday, April 28, 2006

Linguine Maps - Ant Dependency Visualisation

I've been using this tool for some time, to show others how my Ant build files are structured. The output isn't stunning, but it is an extremely practical tool. Go here:

http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=LinguineMapsForApacheAnt

Then click the "Use Online" link. Be sure to select "Apache Ant Build File" as your source type.

QALab - Consolidated Test Stats Tool

I recently came across QALab and though I haven't had a chance to implement it yet, have been impressed by the features it claims to offer. As my testing environment revolves around Junit, Cobertura and PMD, it was nice to see a tool that consolidates all report data from these tools over time, saving space and keeping only essential information. I had been looking at doing something similar, but now it seems I'd be wasting my time. Another nifty feature of this tool is the way it graphs your stats. I could write a couple of paragraphs, but a picture speaks a 1000 words....
















As you can see (though maybe you can't, it's pretty small), QALab combines graphs for PMD, checkstyle, Simian, and findbugs, showing their combined stats over the same period of time. Cobertura is not in the graph above, but is an option within QALab.
Another feature of QALab is the "Movers" report. From the website:
As a project grows, it is increasingly difficult to spot what has changed from one day to the other. This report helps the developers in finding out the changes (up/down) over a specific time window. It then becomes a habit for the developers to correct any "up" movements (increase in the number of violations/errors).

I'll be hoping to implement a mock-up soon and give a more thorough overview of this tool, but from what I've seen so far, it's another useful addition to a test environment.
Check out QALab here:
http://qalab.sourceforge.net/

Summary of Changes between JUnit 3.8.1 and 3.8.2

JUnit 3.8.2 was recently released EXTREMELY discreetly, as JUnit 4 (now 4.1) was also released. While there is plenty of documentation on the new features in JUnit 4, I found little to nothing on what changes had been made between JUnit 3.8.1 and 3.8.2. At least nothing on the web.
Check out an overview of the changes first here:
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3278
For more detailed information, there is a changelog included in the binary distribution (and probably the source, but I haven't checked it out). However, for the benefit of having it on the web, I 've included the changelog here:
=========================

Summary of Changes between 3.8.1 and 3.8.2

The changes between the versions are minimal and the focus was on fixing the accumulated bug reports. The most signifanct change is replacing the much-reviled string comparison format with something easier to read and use.
  • ComparisonFailure shows context.
    • assertEquals("Mary had a little lamb", "Mary had the little lamb") shows: expected: but was:
      Longer prefixes and suffixes are truncated to a fixed size (currently 20):
    • expected:<...st of the emergency [broadcasting] system> but was:<...st of the emergency [locating] system>
  • Running single tests. junit.ui.TestRunner can be invoked with "-m ClassName.testName" to run a single test.
  • TestSuite(Class[]). There is a new TestSuite constructor that takes an array of classes as a parameter and returns a suite of suites, each of which is constructed from a single class.

Closed Bugs/Patches and Enhancment Requests

==========================
Hope that helps some of you out.

Testing JUnit tests with Jester

Came across an interesting article about a tool called Jester here:
http://www-128.ibm.com/developerworks/java/library/j-jester/
It's recommended as a complimentary tool to whatever code coverage tool you use.
From the website:

Jester finds code that is not covered by tests. Jester makes some change to your code, runs your tests, and if the tests pass Jester displays a message saying what it changed. Jester includes a script for generating web pages that show the changes made that did not cause the tests to fail.

Jester is different than code coverage tools, because it can find code that is executed by the running of tests but not actually tested. Jester's approach is called mutation testing or automated error seeding. However, Jester is not meant as a replacement for code coverage tools, merely as a complementary approach.

I'll have to have a closer look at it to see just how effective it is, but I'll leave you with a word from one of the original JUnit developers:

“Why just think your tests are good when you can know for sure? Sometimes Jester tells me my tests are airtight, but sometimes the changes it finds come as a bolt out of the blue. Highly recommended.”
Kent Beck

You can find out more about Jester here:

http://jester.sourceforge.net/

Thursday, April 27, 2006

Re-installing PMD Eclipse Plugin

It has happened on more than one occasion that the Eclipse PMD plugin has gotten well and truly messed up. Through trial and error, I can recommend the following actions as a cure to an ill installation of the PMD plugin.
  1. Open up Eclipse.
  2. If you have the PMD perspective open, close it.
  3. On the "Help" menu, click "Software Updates", then "Manage Configuration"
  4. Expand the "c:\eclipse" (assuming that's where it's installed) option
  5. You should see "PMD for Eclipse 3 x.x.x" or "PMD for Eclipse 2 x.x.x"
  6. Click on whatever PMD plugins are listed and click the disable link in the right-hand pane.
  7. When asked "Do you want to disable this feature?" click "OK"
  8. Restart the Workbench as requested
  9. Repeat steps 3 and 4
  10. You should not be able to see the PMD plugin listed. To see all disabled plugins, click the "Show Disabled Features" button.

  11. The PMD plugin should now be listed.
  12. When you click on the PMD plugin, the right-hand pane will give you the option to Uninstall the plugin. Click the Uninstall Link
  13. When prompted "Do you want to uninstall this feature", click OK.
  14. Restart the workbench as suggested.
  15. For a clean installation of PMD, some extra steps must be taken.
    1. Close Eclipse and run the Eclipse.exe file with the -clean switch. This will remove any old PMD manifests.
    2. Within your Eclipse directory, there will be directories for each of your projects. Within these project directories, PMD may have stored settings related to the plugin. You need to delete these files.
    3. Delete any files with PMD in their name or having a ".pmd" extension.
      Obviously if you have source code that you yourself have written with PMD in the filename, then do not delete those files.
    4. Repeat step 1.
  16. Now we can re-install the plugin. With Eclipse open, click "Help" -> "Software Updates" and then "Find and Install"
  17. Select the "Search for new features to Install" option and click "Next"
  18. To be completely safe you should remove any references to PMD sites you have already defined. You can do that by highlighting the site and then clicking the "Remove" button.
  19. Once you have removed all PMD related sites, click the "New Remote Site" button.
  20. Enter PMD (or whatever catches your fancy) for the name, and http://pmd.sourceforge.net/eclipse for the site. Then click "OK"
  21. Your PMD site should now be listed. Tick the check box beside it and click "Finish"
  22. Eclipse should find the PMD plugin. Tick the checkbox beside it and click "Next"
  23. Accept the terms of the license agreement (If you like) and click "Next"
  24. You can then accept the default install location or choose your own. Once you've done that, click "Finish"
  25. The PMD plugin will then be downloaded in the background.
    BE WARNED!
    The sourceforge servers seem to be as reliable as a '78 Lada Riva 2000 (not very). The speed that the plugin downloads can vary so give it time. Also sometimes you can get an "Exception Occured" error. It will ask you if you would like to retry the download, and I suggest you do so.
  26. Once it has been downloaded, click the "Install" button.
  27. Restart the workbench as suggested.
  28. A good indicator of whether the install has succeeded is to do the following
    1. Click "Window" -> "Preferences".
    2. Select the PMD preferences option and expand it.
    3. Click the "Rule Configuration" option.
    4. If the install has succeeded, you should see add/import/export rules and a list of available rules.
      If the install failed then you'll see a big grey area where the rule options should be. Maybe you'll get an error message if you're lucky.
    5. The key cause of the error message is not deleting the pmd files stored in the project directory, as mentioned in step 15. Check and double-check that all PMD related files have been deleted.
  29. Start using PMD!
That took a hell of a lot longer than I expected.....

Whats this all about then?

This blog is intended to shed some light on some java build/test tools I've been using in work. Invariably they are open-source, but if I come across any interesting commercial product issues/articles I will also include them. Any comments are appreciated.