Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions TUnit.Example.Asp.Net.TestProject/FactoryMethodOrderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ namespace TUnit.Example.Asp.Net.TestProject;
/// Tests verifying the execution order of WebApplicationFactory methods
/// relative to WebApplicationTest hooks.
///
/// Factory methods run after SetupAsync but before test-specific configuration:
/// - Factory.ConfigureWebHost (order 3)
/// - Factory.ConfigureStartupConfiguration (order 4)
/// Factory methods are called when the shared factory is initialized.
/// Per-test web host builder configuration runs after SetupAsync but before
/// test-specific configuration:
/// - ConfigureWebHostBuilder (order 3)
///
/// This allows:
/// - Factory to provide base configuration shared across tests
Expand Down Expand Up @@ -35,19 +36,18 @@ await Assert.That(GlobalFactory.ConfigureStartupConfigurationCallCount).IsGreate
}

[Test]
[DisplayName("Factory.ConfigureWebHost runs after SetupAsync")]
public async Task Factory_ConfigureWebHost_Runs_After_SetupAsync()
[DisplayName("ConfigureWebHostBuilder runs after SetupAsync")]
public async Task ConfigureWebHostBuilder_Runs_After_SetupAsync()
{
_ = Factory.CreateClient();

// Note: Factory order tracking only works reliably when this test triggers factory initialization
// If factory was already initialized, these values are from a previous test's counter
if (FactoryConfigureWebHostCalledOrder > 0)
{
await Assert.That(FactoryConfigureWebHostCalledOrder)
.IsGreaterThan(SetupCalledOrder)
.Because("Factory methods run after SetupAsync (during factory access)");
}
await Assert.That(GlobalFactory.ConfigureWebHostCallCount)
.IsGreaterThan(0)
.Because("ConfigureWebHost should be called when the shared factory is initialized");

await Assert.That(ConfigureWebHostBuilderCalledOrder)
.IsGreaterThan(SetupCalledOrder)
.Because("Per-test web host builder configuration runs after SetupAsync");
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"node-forge": "1.4.0",
"picomatch": "4.0.4",
"svgo": "4.0.1",
"yaml": "2.8.3"
"yaml": "2.8.4"
}
}
8 changes: 4 additions & 4 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9674,10 +9674,10 @@ yallist@^3.0.2:
resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz"
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==

yaml@2.8.3, yaml@^2.8.1:
version "2.8.3"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.3.tgz#a0d6bd2efb3dd03c59370223701834e60409bd7d"
integrity sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==
yaml@2.8.4, yaml@^2.8.1:
version "2.8.4"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.4.tgz#4b5f411dd25f9544914d8673d4da7f29248e5e2e"
integrity sha512-ml/JPOj9fOQK8RNnWojA67GbZ0ApXAUlN2UQclwv2eVgTgn7O9gg9o7paZWKMp4g0H3nTLtS9LVzhkpOFIKzog==

yocto-queue@^1.0.0:
version "1.2.2"
Expand Down
Loading