andres-sacco / api-example-archunit

This repository contains some examples related to the use of Archunit
https://sacco-andres.medium.com/
MIT License
3 stars 1 forks source link

arch unit fails with the following errors on 0.23.1 while does not report the same error with 0.15.0 #4

Open nagkumar opened 2 years ago

nagkumar commented 2 years ago
endra%20Kumar/.m2/repository/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar!/, jar:file:/C:/Users/Raja%20Nagendra%20Kumar/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/]
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 s - in ServiceRulesTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   GeneralCodingRulesTest Rule 'methods that are annotated with @Bean should be public, because @Bean annotation does not work in non public methods' failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the `that()` clause. To allow rules being evaluated without checking any classes you can either use `ArchRule.allowEmptyShould(true)` on a single rule or set the configuration property `archRule.failOnEmptyShould = false` to change the behavior globally.
[ERROR]   GeneralCodingRulesTest Rule 'fields that are static and are final and do not have name 'serialVersionUID' and do not have modifier SYNTHETIC should have name matching '.*^[A-Z].*', because Variables with static and final modifiers should be named in uppercase' failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the `that()` clause. To allow rules being evaluated without checking any classes you can either use `ArchRule.allowEmptyShould(true)` on a single rule or set the configuration property `archRule.failOnEmptyShould = false` to change the behavior globally.
[ERROR]   GeneralCodingRulesTest Rule 'fields that have raw type ch.qos.logback.classic.Logger should be private and should be static and should be final and should have name 'LOGGER', because Logger variables should be private, static and final, and it should be named as LOGGER' failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the `that()` clause. To allow rules being evaluated without checking any classes you can either use `ArchRule.allowEmptyShould(true)` on a single rule or set the configuration property `archRule.failOnEmptyShould = false` to change the behavior globally.
[INFO]
[ERROR] Tests run: 33, Failures: 3, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20.274 s
[INFO] Finished at: 2022-07-25T08:37:26+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project api-example-archunit: There are test failures.
[ERROR]
nagkumar commented 2 years ago

on 0.22.0 no failures were reported.. looks like this issue has come only in 0.23.1

nagkumar commented 2 years ago

in 0.23.0 the error is

-commons-1.7.0.jar!/]
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 s - in ServiceRulesTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   GeneralCodingRulesTest Rule failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the `that()` clause. To allow rules being evaluated without checking any classes you can set the ArchUnit property archRule.failOnEmptyShould = false
[ERROR]   GeneralCodingRulesTest Rule failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the `that()` clause. To allow rules being evaluated without checking any classes you can set the ArchUnit property archRule.failOnEmptyShould = false
[ERROR]   GeneralCodingRulesTest Rule failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the `that()` clause. To allow rules being evaluated without checking any classes you can set the ArchUnit property archRule.failOnEmptyShould = false
[INFO]
[ERROR] Tests run: 33, Failures: 3, Errors: 0, Skipped: 0
[INFO]
nagkumar commented 2 years ago

fix is add archunit.properties with the property

archRule.failOnEmptyShould = false

image