My book PMD Applied has been out for a few months, but now I'm thinking of some things I'd like to be in there. Thus this announcement - I've just released a free supplemental chapter, "Better JUnit Tests With PMD"!
In this chapter I go through the PMD JUnit ruleset and show how you can use each rule to make your JUnit tests cleaner and more informative. Hopefully it will add more to the "PMD Applied" idea in that the chapter is devoted to, well, applying PMD to a particular domain - unit tests. You can download it in PDF format from the book's web site.
Props to my publisher, Centennial Books, for supporting this effort. And of course, if you don't already have a copy of "PMD Applied", now's the perfect time to pick one up!
No TestNG support?
Posted by: x | February 09, 2006 at 12:00 PM
Sounds good to me; what are some good TestNG rules/guidelines/suggestions?
Posted by: tomcopeland | February 09, 2006 at 12:03 PM
Not related to this entry specifically, but how does PMD compare with IntelliJ's static analyser? I wonder what you, and users of PMD, have to say..
(Havne't used PMD yet - Just interested in your own experience/feedbacks you've received)
Posted by: Aviad Ben Dov | February 10, 2006 at 12:31 PM
Hi Aviad -
Well, frankly, at the moment, IntelliJ's static analyzer is much better :-) But PMD's analyzer is pretty good, the price is right, and you can run it from the command line or Ant or whatever, so it works well for a nightly build operation.
Yours,
Tom
Posted by: tomcopeland | February 10, 2006 at 01:01 PM
TestNG is annotation based- a common issue with the version that support Java 1.4 is that the annotations are JavaDoc based. For a test, one must put: @testng.test. For configuration aspects, you have comments like: @testng.configuration beforeTestClass="true". These can easily be flubbed by fat fingers, which can cause confusing results when running TestNG.
A nice rule set would be to validate TestNG JavaDoc comments.
Posted by: Andy | February 16, 2006 at 10:20 AM
You can also turn it around; it's possible to run the PMD tool as a JUnit test among your other tests.
http://blog.christoffer.me/2011/02/running-pmd-another-great-static-code.html
Posted by: Corgrath | February 05, 2011 at 02:31 PM