Freeze Rule Sets
If i am including a rule set in my tests i.e.:
@ArchTest
public final ArchRules ruleSet = ArchRules.in(AnotherClass.class);
Is there a way to freeze all those rules without changing the external class? In the docs I can only see examples for freezing individual rules. i.e. something along the lines of:
@ArchTest
public final ArchRules ruleSet = freeze(ArchRules.in(AnotherClass.class));
Is what I was hoping to find.
Unfortunately that hasn't been implemented yet. I see why this would be useful, but ArchRules follows a completely different pattern than ArchRule, because JUnit 4 and JUnit 5 support each interpret this differently.
I could imagine that it would be possible to support something like this, by introducing a new annotation, like
@Freeze
@ArchTest
public final ArchRules ruleSet = ArchRules.in(AnotherClass.class);
The decorator way would not really work here, because ArchRules is simply a container, but no ArchRule itself, that could be decorated. @Freeze on the other hand could work consistently for ArchRules and ArchRule, because the test infrastructure could just treat those two cases completely differently internally.
Other than that, you could use CompositeArchRule instead of ArchRules, but that is not as concise for bigger rule sets, sorry that I don't have any better news for now.
You could freeze every single rule in AnotherClass and then configure a different ViolationStore in the projects where you include AnotherClass, an empty ViolationStore would treat the rule effectively like unfrozen.