我正在尝试设置一个测试初始化函数来处理一些基本的数据库设置任务;这是我的基类:
[ TestClass]
public class BaseTest
{
private SqlConnection sqlConnection;
protected SqlTransaction sqlTransaction;
[TestInitialize ()]
protected void InitialiseConnection()
{
// Set-up sqlTransaction
}
[ TestCleanup ()]
protected void RollbackConnection()
{
// Cleanup
}
然后我就像这样使用它:
[ TestClass]
public class MyTest : BaseTest
{
[ TestMethod ]
public void MyFirstTest()
{
/// Access DB here crashes because sqltransaction is null
基类的断点显示它没有调用InitialiseConnection
方法。我错过了什么吗?