Unit Testing: Interfaces VS Implementation

Milian Wolff mail at milianw.de
Sat Jun 11 13:38:54 UTC 2011


Hey all,

I have stumbled upon some issues while setting up the unit test 
infrastructure: The separation of interfaces and implementation is troublesome 
when trying to unit test it.

So far, there are at least three unit tests in kdevplatform which - imo - 
should be revised:

* VcsBlackBoxTest (disabled for now)
* ProjectModelTest (requires custom [senseless?] code in project model for the 
case of items without project/projectmanager, i.e. imo not actually testing 
the "real" thing)
* ShellBuddyTest (fails since current implementation lies in KDevelop)

and maybe (I have to investigate it yet)
StandardOutputViewTest

These are basically trying to test the pure interface, which of course only 
works with some kind of implementation. The big issue is the hen-egg problem. 
Only installing KDevplatform and running the unit tests will either fail (no 
implementation found) or only test the (few?) implementations in KDevplatform, 
completely ignoring everything outside (kdevelop / playground / ...).

So what I propose is creating some kind of public TestXYZImplementation class. 
Implementations can then create a unit test 
instantiating/subclassing/implementing this class and run the contained tests. 

The advantages:
- no henn-egg problem, we test when we have something that needs to be tested
- it's clear which implementation fails
- the TestXYZImplementation class in KDevplatform is still only checking the 
basic interface without any implementation details

The cons:
- test class needs to be/have public api (probably?)
- minimal code duplication

What do you think, this should work - right? If so, who would help me in 
porting the code? Together with my GSOC and RL I could need some hands in 
doing the heavy lifting here. Once this is done I think we can have nightly 
builds and unit tests with reports setup in no time.

bye

-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110611/ec83df7b/attachment.sig>


More information about the KDevelop-devel mailing list