我对Aspnet Core MVC
建立一个综合测试项目。
我使用AspNetBoilerplate
。
我创建了这个WebApplicationFactory
项目:
public class CustomWebApplicationFactory : WebApplicationFactory<Program>
{
}
而我的测试类继承
public partial class ScenarioTest : IClassFixture<CustomWebApplicationFactory>
{
当我运行整个测试套件,我既得到这些错误:
Castle.MicroKernel.ComponentRegistrationException : Component iloggerfactory could not be registered. There is already a component with that name. Did you want to modify the existing component instead? If not, make sure you specify a unique name.
System.ArgumentException : Facility of type 'Castle.Facilities.Logging.LoggingFacility' has already been registered with the container. Only one facility of a given type can exist in the container.
Castle.MicroKernel.Handlers.HandlerException : Can't create component 'Microsoft.Extensions.Logging.ILoggerProvider_e02ce050-f09e-48d5-b518-57e4ee2ef81b' as it has dependencies to be satisfied.
然后,当我尝试运行测试套件第二次,我得到这样的:
清洁测试项目,并重新运行它使错误再次出现
虽然,我可以运行一个单一的测试类(ReSharper的),以及测试类运行成功。
帮助这将不胜感激,因为我不能运行连续测试会议,它是很烦人
更改WebApplicationFactory<Program>
到WebApplicationFactory<Startup>
。