BenMorris/NetArchTest

Highlighting "why" a type fails test

Closed this issue · 5 comments

In my tests I am outputting the types that fail the test. However what would be great is to identify the reason why that type fails the test.

e.g.

var result = Types.InAssembly(typeof(Foo).Assembly)
    .Should()
    .OnlyHaveDependenciesOn(new string[] { "Bar" })
    .GetResult();

Assert.True(result.IsSuccessful, GetFailingTypes(result));

It would be great to see the dependencies causing the violation. Is there any means to do that at present?

I'm afraid not - the whole execution chain is predicated on building up a list of types that pass or fail rules (see FunctionSequence.Execute()). It doesn't retain any other metadata around why a rule failed for each type.

How can I vote for this as a feature request? I have struggled for two hour now to figure out why two simple types of mine fail.

Implementing that would require too many breaking changes, including performance profile/impact, thus I do not think that this will be ever implemented here. I have started the parallel project, that allows sending metadata alongside the type, and I have in mind this issue, but right now I do not have the motivation to push it forward.

@thomaseyde we switched to ArchUnitNET, which according to nuget uses this project as a dependency and does report on failure reasons.