by Anonymous » 24 Feb 2025, 00:50
Ich versuche, Integrationstests auszuführen und diesen Fehler zu erhalten. Microsoft.extensions.hosting.hostfactoryResolver.HostingListener.CreateHost ()
at Microsoft.extensions.hosting.hostfactoryResolver. C__DisplayClass10_0.b__0 (String [] args)
at microsoft.aspnetcore.mvc.testing.deferredhostbuilder.build ()
at microsoft.aspnetcore.mvc.testing. WebApplicationFactory
Code: Select all
1.CreateHost(IHostBuilder builder) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory< /code> 1.Configurehostbuilder (iHostBuilder Hostbuilder)
unter microsoft.aspnetcore.mvc.testing.WebApplicationFactory1.EnsureServer() at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory< /code> 1. CreatedefaultClient (DelegatingHandler [] Handler)
at microsoft.aspnetcore.mvc.testing.WebApplicationFactory1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory< /code> 1. CreatEclient (WebApplicationFactoryClientOptions -Optionen)
unter ptco.system.integrationstests.infrastructure.integrationTestswebfactory.CreteManagedClient () in C: \ Users \ nemes \ Dokumente \ Github \ ptco.app \ System \ ptco.System.Integrationstests \ Infrastruktur \ IntegrationTestSwebfactory.cs: Zeile 249 < /p>
Zeile 249 ist < /p>
private HttpClient CreteManagedClient() =>
CreateClient(new WebApplicationFactoryClientOptions
{
BaseAddress = new Uri(_configuration.GetValue("IntegrationServerBaseUri"))
});
< /code>
Das heißt so < /p>
public IntegrationTestsWebFactory()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
_configurationPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json");
_configuration = BuildConfiguration();
ManagedHttpClient = CreteManagedClient();
}
Wie kann ich diesen Fehler lösen?
Ich versuche, Integrationstests auszuführen und diesen Fehler zu erhalten. Microsoft.extensions.hosting.hostfactoryResolver.HostingListener.CreateHost ()
at Microsoft.extensions.hosting.hostfactoryResolver. C__DisplayClass10_0.b__0 (String [] args)
at microsoft.aspnetcore.mvc.testing.deferredhostbuilder.build ()
at microsoft.aspnetcore.mvc.testing. WebApplicationFactory[code]1.CreateHost(IHostBuilder builder) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory< /code> 1.Configurehostbuilder (iHostBuilder Hostbuilder)
unter microsoft.aspnetcore.mvc.testing.WebApplicationFactory1.EnsureServer() at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory< /code> 1. CreatedefaultClient (DelegatingHandler [] Handler)
at microsoft.aspnetcore.mvc.testing.WebApplicationFactory1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory< /code> 1. CreatEclient (WebApplicationFactoryClientOptions -Optionen)
unter ptco.system.integrationstests.infrastructure.integrationTestswebfactory.CreteManagedClient () in C: \ Users \ nemes \ Dokumente \ Github \ ptco.app \ System \ ptco.System.Integrationstests \ Infrastruktur \ IntegrationTestSwebfactory.cs: Zeile 249 < /p>
Zeile 249 ist < /p>
private HttpClient CreteManagedClient() =>
CreateClient(new WebApplicationFactoryClientOptions
{
BaseAddress = new Uri(_configuration.GetValue("IntegrationServerBaseUri"))
});
< /code>
Das heißt so < /p>
public IntegrationTestsWebFactory()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
_configurationPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json");
_configuration = BuildConfiguration();
ManagedHttpClient = CreteManagedClient();
}
[/code]
Wie kann ich diesen Fehler lösen?