Click here to Skip to main content
15,881,598 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why test an interface? Why not just test the concrete object(s) of that interface?
Posted
Updated 13-May-10 13:04pm
v2

IMO since interfaces do not contain any code, you should not waste time writing tests for them (what is there to test?), if you are talking about interfaces in C#. Test the classes that implement the interface and let it go at that.
 
Share this answer
 
Comments
[no name] 13-May-10 9:35am    
That is what I believe also but a google search will result in discussions about using Mock objects.
Doesn't seem like there is a point though, as you said why not test the classes that impliment it.. Then you have it covered.
I just wanted to see if anyone knew something I was missing.
[no name] 13-May-10 16:00pm    
I do not believe that Mocking an object is the same as testing an interface. Mocking is supplying the unit under test with a fake object so that you can proceed with testing an object without introducing possible bugs from another object. I do not see the two being the same thing at all. And yes it makes my eyes cross when I read it too.
Creating a mock object does not necessarily mean that the interface will be tested - a mock object is essentially 'acting as a proxy' for another object that may not be available during testing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900