Reputation: 3339
I want to enforce certain dependency rules in our code base: e.g. package A should not depend on package B, no circular dependencies etc. And I think the only way that is able to enforce them are (failing) tests, not reports.
So I looked around and found JDepend, Classycle and JBoss TattleTale - all appear to be discontinued and lacking Java 8 support. That's when I discovered FindBugs.
So I want to use FindBugs to analyze our package structure and use JUnit to validate certain rules about their relations. But since the FindBugs source code is huge, I'm wondering: How do I achieve this?
Regards, Stephan
Upvotes: 1
Views: 331
Reputation: 359
Nowadays you can use ArchUnit to declare allowed/disallowed dependencies between packages in a form of unit test (JUnit or other test framework), there are some examples in their user guide, a sample looks like this:
noClasses().that().resideInAPackage("..utils..")
.should().dependOnClassesThat().resideInAPackage("..domain..")
Upvotes: 0
Reputation: 24510
You can use Degraph for this task: http://blog.schauderhaft.de/2014/07/27/test-your-dependencies-with-degraph/
Upvotes: 2