I get this error when testing one of my methods that makes WCF service calls, and at service invocation I get this error :
Could not find default endpoint element that references contract ‘XYZ.IMyInterface’ in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
This happens because the wcf service configuration is possibly missing from app.config file of the test project.
So add service configuration from app.config of the wcf library project and copy it to your test project.
This can also happen if WCF service is in a dll, and that dll is being invoked from another startup project, so then the config will need to be in app.config of the startup project.