TNG / ArchUnitNET

A C# architecture test library to specify and assert architecture rules in C# for automated testing.
Apache License 2.0
826 stars 55 forks source link

Failing Domain rules test on Azure pipeline only #186

Closed cuvaalex closed 3 months ago

cuvaalex commented 1 year ago

Hi, I got a really weird issue, on my computer it work perfectly, but on the Azure pipeline it fails, and complain my Domain objects depends on System namespace

The test

  [Fact]
    public void CanOnlyAccessDomainItselfAndExceptions() =>
        DomainTypes()
            .Should()
            .OnlyDependOnTypesThat()
            .ResideInNamespace($"{Namespaces.Domain}|{Namespaces.Exceptions}", true)
            .Check();

The fail log :

[xUnit.net 00:00:01.51]     XXXX.DevSecOps.Lab.HelloWorld.System.Test.ArchitectureRules.DomainRules.CanOnlyAccessDomainItselfAndExceptions [FAIL]
  Failed XXXX.DevSecOps.Lab.HelloWorld.System.Test.ArchitectureRules.DomainRules.CanOnlyAccessDomainItselfAndExceptions [28 ms]
  Error Message:
   ArchUnitNET.xUnit.FailedArchRuleException : "Types that reside in namespace with full name matching "Domain" should only depend on types that reside in namespace with full name matching "Domain|Exceptions|System.Runtime.CompilerServices"" failed:
    XXXX.DevSecOps.Lab.HelloWorld.Core.Domain.HelloWorlds.HelloWorldEntity does depend on System.Object and System.IEquatable`1 and System.Type and System.Void modreq(System.Runtime.CompilerServices.IsExternalInit) and Coverlet.Core.Instrumentation.Tracker.XXXX.DevSecOps.Lab.HelloWorld.Core_73602135-9a35-4cbe-8b48-535f79d08309 and System.String and System.Text.StringBuilder and System.Boolean and System.Int32 and System.Collections.Generic.EqualityComparer`1
    XXXX.DevSecOps.Lab.HelloWorld.Core.Domain.HelloWorlds.HelloWorldId does depend on System.ValueType and System.Int64 and Coverlet.Core.Instrumentation.Tracker.XXXX.DevSecOps.Lab.HelloWorld.Core_73602135-9a35-4cbe-8b48-535f79d08309
    XXXX.DevSecOps.Lab.HelloWorld.Core.Domain.HelloWorlds.HelloWorldName does depend on System.ValueType and System.String and Coverlet.Core.Instrumentation.Tracker.XXXX.DevSecOps.Lab.HelloWorld.Core_73602135-9a35-4cbe-8b48-535f79d08309
    XXXX.DevSecOps.Lab.HelloWorld.Core.Domain.Common.Guards.Guard does depend on System.Object and System.Func`1 and System.String and Coverlet.Core.Instrumentation.Tracker.XXXX.DevSecOps.Lab.HelloWorld.Core_73602135-9a35-4cbe-8b48-535f79d08309 and System.Boolean
    XXXX.DevSecOps.Lab.HelloWorld.Core.Domain.Common.Guards.LongGuardExtensions does depend on System.Object and System.Int64 and System.String and Coverlet.Core.Instrumentation.Tracker.XXXX.DevSecOps.Lab.HelloWorld.Core_73602135-9a35-4cbe-8b48-535f79d08309 and System.Func`1 and System.Boolean
    XXXX.DevSecOps.Lab.HelloWorld.Core.Domain.Common.Guards.StringGuardExtensions does depend on System.Object and System.String and Coverlet.Core.Instrumentation.Tracker.XXXX.DevSecOps.Lab.HelloWorld.Core_73602135-9a35-4cbe-8b48-535f79d08309 and System.Func`1 and System.Boolean

  Stack Trace:
     at ArchUnitNET.xUnit.ArchRuleAssert.CheckRule(Architecture architecture, IArchRule archRule)
   at ArchUnitNET.xUnit.ArchRuleExtensions.Check(IArchRule archRule, Architecture architecture)
   at XXXX.DevSecOps.Lab.HelloWorld.System.Test.ArchitectureRules.ArchUnitExtensions.Check(IArchRule rule) in /home/vsts/work/1/s/test/XXXX.DevSecOps.Lab.HelloWorld.System.Test/ArchitectureRules/ArchUnitExtensions.cs:line 17
   at XXXX.DevSecOps.Lab.HelloWorld.System.Test.ArchitectureRules.DomainRules.CanOnlyAccessDomainItselfAndExceptions() in /home/vsts/work/1/s/test/XXXX.DevSecOps.Lab.HelloWorld.System.Test/ArchitectureRules/DomainRules.cs:line 28
MSinstein commented 1 year ago

Hi @cuvaalex ,

interesting, could you find out what the difference is between local and pipeline run? I would say it is expected that the test fails since your classes actually have other dependencies, right?

alexanderlinne commented 3 months ago

Since we can't reproduce this issue we will close this for now.

@cuvaalex Please feel free to reopen this issue if you can provide a reproducible example for the issue.