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

The tests are running too late #225

Open EngRajabi opened 6 months ago

EngRajabi commented 6 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 6 months ago

This number reached 7 minutes

EngRajabi commented 2 months ago

Is there a way to speed this up? @alexanderlinne

alexanderlinne commented 2 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 2 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 2 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.