我正在尝试使用Fitnesse和FitSharp在我的Web应用程序的DAL中测试方法。我在阅读app.config时遇到问题。
获取错误:
System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. ---> System.NullReferenceException:
Object reference not set to an instance of an object.
at ...DAL.get_ConnectionString()
这是在getter中
get{
var result = ConfigurationManager.ConnectionStrings["CN1"].ConnectionString;
if (String.IsNullOrEmpty(result))
throw new NoNullAllowedException("Connection string does not exist");
return result;
}
为什么ConfigurationManager未初始化?
如何配置Fitnesse以测试DAL?
感谢您的任何建议
答案 0 :(得分:1)
我相信你需要make Fit Sharp aware of your App.config file:
c:\program files\fitsharp\runner -a c:\mypath\myapp.exe.config
-c c:\myfolder\mysuite.config.xml
-r fit.Runner.FolderRunner,c:\program files\fitsharp\fit.dll