0
您认为这是测试异常和抛出的好方法吗?有什么建议么?预期异常单元测试
这是我的代码魔女我沃尔德想测试异常:
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void EstablishEndGetConnectionTest()
{
DbRepository core = null;
core = DbRepository.GetInstance();
core.EstablishConnection("postgres", "1234");
Assert.IsTrue(core.IsConnected);
}
同类问题:http://stackoverflow.com/questions/933613/how-do-i-use-assert-to-verify-that-an-exception-has-been-thrown – Ulric