Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Design testing
Why test an interface? Why not just test the concrete object(s) of that interface?
Posted 13-May-10 3:20am
Edited 13-May-10 13:04pm
Moak11.4K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Collin Jasnoch at 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.
Wes Aday at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 13 May 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100