我正在编写Web,当使用NUnit进行单元测试时,我遇到了以下错误:
Tests.DemoTest.SessionLogOnBreakdownTest:
SetUp : Effort.Exceptions.EffortException : The Effort library failed to register its provider automatically, so manual registration is required.
a) Call the Effort.Provider.EffortProviderConfiguration.RegisterProvider() method at entry point of the application
or
b) Add the following configuration to the App.config file:
<system.data>
<DbProviderFactories>
<add name="Effort.Provider"
invariant="Effort.Provider"
description="Effort.Provider"
type="Effort.Provider.EffortProviderFactory, Effort" />
</DbProviderFactories>
</system.data>
----> System.Configuration.ConfigurationErrorsException : Failed to find or load the registered .Net Framework Data Provider.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.下面是我正在运行的测试:
[TestFixture]
public class DemoTest : TestBase
{
private TestContext _context;
private DbConnection _dbConnection;
[SetUp]
public void Initialization()
{
//Effort.Provider.EffortProviderConfiguration.RegisterProvider();
_dbConnection = Effort.DbConnectionFactory.CreateTransient();
_context = new TestContext(_dbConnection);
}
[Test]
public void SessionLogOnBreakdownTest()
{
//code which uses _context
}
}在_dbConnection = Effort.DbConnectionFactory.CreateTransient();引发错误
我已采纳了例外情况所提出的两项建议。但都没起作用。
我尝试过的事情:
发布于 2020-07-10 07:09:39
在使用.Net (6.4.0-6.4.4)和Effort.EF6 2.2.10的EF6 4.6.1应用程序中,我也看到了这种情况。我尝试过几个不同的版本组合,但通过VS中的测试资源管理器( test )看到它随机发生,并且几乎一致地通过dotnet测试。注意,我尝试了错误信息中提出的A、B和A&B解决方案。
https://stackoverflow.com/questions/43388713
复制相似问题