Skip to content

[Bug]: Incorrect integration test lifecycle order #5195

@ShawnTheBeachy

Description

@ShawnTheBeachy

Description

In the docs it says that Factory.ConfigureWebHost is supposed to run as step 3, then ConfigureTestConfiguration as step 5. However, I'm seeing different behavior; my ConfigureTestConfiguration method is being executed before Factory.ConfigureWebHost, meaning that I'm unable to override the app config.

Expected Behavior

The methods should run in the order the documentation says they do.

Actual Behavior

The methods do not run in the order the documentation says they do.

Steps to Reproduce

public abstract class TestsBase : WebApplicationTest<WebApplicationFactory, Program>
{
    protected override void ConfigureTestConfiguration(IConfigurationBuilder config)
    {
        // Should run as step 5.
    }
}

public sealed class WebApplicationFactory : TestWebApplicationFactory<Program>
{
    protected override void ConfigureWebHost(IWebHostBuilder builder)
    {
        // Should run as step 3.
    }
}

TUnit Version

1.19.74

.NET Version

10

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions