TNG / ArchUnitNET

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

The tests are running too late #225

Closed EngRajabi closed 2 months ago

EngRajabi commented 11 months ago

Consider the following test. It takes about 3 minutes to run. Can I reduce this time?

    private static readonly Assembly[] AssembliesService = Assemblies
        .Where(r => r.FullName!.Contains("ind", StringComparison.OrdinalIgnoreCase) &&
                    r.FullName.Contains("service", StringComparison.OrdinalIgnoreCase))
        .ToArray();

    private static readonly Architecture Architecture =
        new ArchLoader().LoadAssemblies(AssembliesService).Build();

    private static readonly IObjectProvider<Class> EventClasses =
        Classes().That().AreAssignableTo(typeof(EventMessageBaseHandler<>)).As("EventHandler Classes");

    [Fact]
    public void EventClassesShouldHaveCorrect()
    {
        try
        {
            Classes().That().AreAssignableTo(EventClasses)
                .Should().HaveNameEndingWith("EventProcessor")
                .AndShould().BePublic()
                .AndShould().BeSealed()
                .OrShould().BeAbstract()
                .Check(Architecture);
        }
        catch (TypeDoesNotExistInArchitecture)
        {
            //ignored
        }
    }
EngRajabi commented 11 months ago

This number reached 7 minutes

EngRajabi commented 7 months ago

Is there a way to speed this up? @alexanderlinne

alexanderlinne commented 7 months ago

Hi @EngRajabi, would you be able to provide an example that reproduces this issue? Ideally a GitHub Link to an example repository.

EngRajabi commented 7 months ago

Hi @EngRajabi, would you be able to provide an example that reproduces this issue? Ideally a GitHub Link to an example repository.

My repository is private, I cannot share it with you. This sample test, which is sent to you, takes about 8 minutes

alexanderlinne commented 7 months ago

We of course wouldn't need access to your private repository. Your sample test may take eight minutes on your project, but we obviously can't reproduce this with just the test.

If you'd want our support in investigating this specific issue we'd need you to create a public repository with a minimal example that reproduces this issue.

alexanderlinne commented 2 months ago

Closing this due to inactivity. Feel free to reopen this with an example that reproduces the issue