ArchUnitNET icon indicating copy to clipboard operation
ArchUnitNET copied to clipboard

Improve error messages for predicates

Open mak638 opened this issue 5 months ago • 0 comments

There are multiple places where the error messages for failed tests with predicates are not making sense or are simply repeating the query without giving any more information about the violation.

In particular the following snapshots should be reworked:

Ex. 1: ObjectSyntaxElementsTests.CallAnyTest.verified.txt

Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithSingleDependency()" should be method members that do not call any method
Result: False
Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithSingleDependency() does exist
Message: 
"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithSingleDependency()" should be method members that do not call any method" failed:
	System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithSingleDependency() does exist

Ex. 2: ObjectSyntaxElementsTests.DependOnAnyTest.verified.txt

----- Predicates as conditions -----

Query: Types that are "TypeDependencyNamespace.ClassWithMultipleDependencies" should be types that depend on any of no types (impossible)
Result: False
Description: TypeDependencyNamespace.ClassWithMultipleDependencies does exist
Message: 
"Types that are "TypeDependencyNamespace.ClassWithMultipleDependencies" should be types that depend on any of no types (impossible)" failed:
	TypeDependencyNamespace.ClassWithMultipleDependencies does exist

Ex. 3: ObjectSyntaxElementsTests.HaveAnyAttributesTest.verified.txt

----- Predicates as conditions -----

Query: Types that are "AttributeNamespace.ClassWithTwoAttributes" should be types that have any of no attributes (always empty)
Result: False
Description: AttributeNamespace.ClassWithTwoAttributes does exist
Message: 
"Types that are "AttributeNamespace.ClassWithTwoAttributes" should be types that have any of no attributes (always empty)" failed:
	AttributeNamespace.ClassWithTwoAttributes does exist

Ex. 4: ObjectSyntaxElementsTests.HaveNameTest.verified.txt

Query: Types that are "TypeDependencyNamespace.BaseClass" should be types that have name "BaseClass"
Query: Types that are "TypeDependencyNamespace.BaseClass" should be types that have name "TypeDependencyNamespace.BaseClass"
Result: True
Result: False
Description: TypeDependencyNamespace.BaseClass passed
Description: TypeDependencyNamespace.BaseClass does exist

Ex. 5: ObjectSyntaxElementsTests.OnlyDependOnTest.verified.txt

----- Predicates -----

Query: Types that are "TypeDependencyNamespace.ClassWithMultipleDependencies" should be Types that depend on no types
Result: False
Description: TypeDependencyNamespace.ClassWithMultipleDependencies is not Types that depend on no types
Message: 
"Types that are "TypeDependencyNamespace.ClassWithMultipleDependencies" should be Types that depend on no types" failed:
	TypeDependencyNamespace.ClassWithMultipleDependencies is not Types that depend on no types

Ex. 6: ObjectSyntaxElementsTests.OnlyHaveAttributesTest.verified.txt

Query: Types that are "AttributeNamespace.ClassWithSingleAttribute" should be Types that have no attributes
Result: False
Description: AttributeNamespace.ClassWithSingleAttribute is not Types that have no attributes
Message: 
"Types that are "AttributeNamespace.ClassWithSingleAttribute" should be Types that have no attributes" failed:
	AttributeNamespace.ClassWithSingleAttribute is not Types that have no attributes

mak638 avatar Sep 26 '25 18:09 mak638