问题
When calling a WCF service from a console app, asp.net app, wpf/winform app, you have to have a app.config or web.config file for the WCF service endpoint information. But from FitNesse, I'm calling a fixture which is a .dll (class library) and this fixture is calling my WCF service. It can't call the service because I can't include the endpoint information that it needs - because DLLs can't have app.config files. Any ideas on how to call a WCF service from FitNesse.
回答1:
Anything you can do with a config in WCF can also be done programmatically. Could you create the endpoints in code and then compile it?
回答2:
I had to place my app.config file in the dotnet directory of FitNesse. I also had to add a path to that config file in my FitNesse page, like this.
!path C:\fitnesse20090214\fitnesse\dotnet\app.config
回答3:
A similar approach that I have working is to make a copy of the app.config for the testrunner.
So I make a copy of app.config as FitServer.exe.config (and TestRunner.exe.config) as a post build step in my fixture project.
As the previous post indicates, the config file needs to be in the same directory as the runner.
This worked with the 1.6 version of the fitnesse .Net runners as well as the latest 20090214 release.
来源:https://stackoverflow.com/questions/635210/how-to-call-a-wcf-service-from-fitnesse