#22 Difficult to unit test: Remove final on public methods

open
API (15)
5
2006-08-25
2006-08-25
No

It is extremely difficult to unit test with the Informa
code because to many of the public methods have been
made final.

For instance:

One common way to unit test code that might use the
library is to create a "fake" object that overrides the
methods of the original in order to inject it into the
code under test.

e.g. If I'm writing code that contains logic for the
Poller class, I'll test it by creating a FakePoller
(public class FakePoller extends Poller). Of course,
since this is a unit test, I don't actually want Poller
to do anything, I just want the code under test to
think it's using a Poller so I can control its inputs
and outputs.

Please remove the unnecessary final designation on
public methods so the API can be better used when unit
testing the code that uses it.

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks