I am unable to test my log4net library using nunit. I read the search results returned by Google but could not understand them.
This is the error that I am getting.
System.IO.FileNotFoundException : Could not load file or assembly
‘log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304’ or one of its dependencies. The
system cannot find the file specified.
In my nunit test project I have added the reference to correct log4net dll that rest of the projects are using and added the configuration files but no luck.
My Console application and test web application that use the log4net libaray are working correctly.
I seem to only have problem with log4net nunit test project.
How can I get started with simple nunit test involving log4net library.
You should be accepting an ILog in whatever you’re trying to test. Then you should mock it and pass it to whatever you’re attempting to test. The version of log4net shouldn’t matter at all. Your tests shouldn’t even know log4net exists.
Using Rhinomocks, this would be:
Alternatively you could go with a stub: