如何在NUnit中运行此测试
问题描述:
为什么在我写NUnit时: Assert.AreEqual(ConfigurationManager.ConnectionStrings [“FertigungRead”] .ConnectionString,“Data Source = server511; Initial Catalog = FERTIGUNG; Persist Security Info = True” );如何在NUnit中运行此测试
它不运行测试并引发错误:未将对象引用设置为对象的实例。
但ConfigurationManager是静态类。那么我该如何运行这个测试呢?
答
它是运行测试 - 但测试失败,因为ConfigurationManager.ConnectionStrings["FertigungRead"]
返回null。 请参阅this post about app.config files an NUnit,因为这是从哪里获取配置。
但是,我真的没有看到配置文件值的测试作为有价值的单元测试...是更合理测试的一部分吗?
检查我的答案你的其他问题之一http://stackoverflow.com/questions/2409208/the-problem-with-nunit-and-app-config/5821977#5821977 – skyfoot 2011-05-04 17:12:16