Eric Siegal
Eric Siegal

Reputation: 268

Can I run PMD analysis in a Junit test?

I would like to create an automated junit test that passes if my code meets the requirements specified by PMD, and fails if it does not. Is this possible?

Upvotes: 0

Views: 319

Answers (1)

eclipse-pmd
eclipse-pmd

Reputation: 545

It is possible tu run a PMD analysis in a JUnit test. However, there exist PMD plugins for every Java IDE, build and CI tool out there. Are you sure they don't already do what you want to achieve?

If you still want to do it yourself, take a look at the class PMD. It has the static method PMD.doPMD(configuration) which starts the analysis.

The same class also contains the main method in case you want to start it like from the command line.

Upvotes: 1

Related Questions