Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure message reports the broken types, but not how they are broken #151

Open
thomaseyde opened this issue Jan 5, 2025 · 0 comments
Open

Comments

@thomaseyde
Copy link

I have written my first test where I want to assert that a namespace only depends on itself. I think that should be an easy test to write, the use case should be very common, but the library doesn't support that.

The TestResult only contains failed types, and not the invalid types they depend on.

The test still fails after I have fixed the obvious mistakes. There are no more invalid using statements in my source, which make me suspect I use some of the global dependencies found in the generated GlobalUsings.g.cs:

global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using global::Xunit;

I included all of them in my test, but it still fails:

        var types = Types.InCurrentDomain();

        var result = types.That().ResideInNamespace("EventSourcingExplorations.EventSourcing")
                          .Should().OnlyHaveDependenciesOn(
                              "EventSourcingExplorations.EventSourcing",
                              "EventSourcingExplorations.EventSourcing.Exceptions",
                              // GlobalUsings.g.cs below
                              "System",
                              "System.Collections.Generic",
                              "System.IO",
                              "System.Linq",
                              "System.Net.Http",
                              "System.Threading",
                              "System.Threading.Tasks",
                              "Xunit",
                              "EventSourcingExplorations.EventSourcing.Exceptions"
                          )
                          .GetResult();

        result.FailingTypeNames.Should().BeEmpty();

This project is a wonderful initiative, and something really needed. But I cannot use this if I have to dig into generated files and understand the internals.

Please, add a member to TestResult which expose each broken type with their invalid dependencies. While not perfect, it would be so much easier to identify coding mistakes or to fine tune the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant