Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add test in a project to check if our rules are really applied #1348

Open
pkernevez opened this issue Aug 30, 2024 · 1 comment
Open

Comments

@pkernevez
Copy link

pkernevez commented Aug 30, 2024

I don't find an information on how to do it.

I tried Stack Overflow too, without success.

We have about 40 rules on our base code and I want to check automatically that the rules are still validating what is expected.

@hankem
Copy link
Member

hankem commented Oct 12, 2024

Essentially as suggested by Larry Diamond's Stack Overflow answer:
To ensure that a rule catches a certain violation, you should have a unit test evaluate the rule with an intentional violation (which can be defined in a local test scope, cf. #930 (comment)), and assert that the expected failure is obtained.

GeneralCodingRulesTest and LayeredArchitectureTest are two examples for ArchUnit's own unit tests for rules.
They use ArchRuleAssertion and ArchRuleCheckAssertion, which are currently (as of ArchUnit 1.3.0) not provided by ArchUnit, but are straight forward implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants