ArchUnit icon indicating copy to clipboard operation
ArchUnit copied to clipboard

How to fail tests if no classes are imported?

Open bbadjari opened this issue 1 year ago • 1 comments

Is there a convenient way to fail tests when no classes are imported via ClassFileImporter? I found some old tests that continued to pass even though they were doing nothing useful because ClassFileImporter was attempting to import classes from a package (via the importPackages() method) that no longer existed.

bbadjari avatar Jun 26 '24 15:06 bbadjari

Since #774 (released with ArchUnit 0.23.0), ArchUnit can Fail Rules on Empty Should, i.e. when the should-part of rules is evaluated against an empty set of classes, which should catch your case.

You're not accidentially using an archunit.properties file with archRule.failOnEmptyShould=false (or even a very old version of ArchUnit), are you?

hankem avatar Jun 26 '24 19:06 hankem

Gonna close this for now, feel free to reopen if you want to pick this up gain!

codecholeric avatar Nov 10 '24 10:11 codecholeric