Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Junits & Mockito

If you want to write actual unit tests, rather then run whole eclipse to test one function,
Mockito framework is awesome.
It allows you mock everything around class you are testing. So you don't even have
to run eclipse to test your stuff.
Recently I included it in runtime target (for master), so you can just start using it in tests (add dependency to org.mockito).

If you want examples of usage I just wrote around 50 tests for LaunchBarManager
all of them can run without eclipse and in less then a second
(in org.eclipse.cdt.launchbar.core.tests)

In these tests I am mocking IProject, ILaunchConfiguration and much more so I don't
have to actually create it.

The drawbacks are - it cannot mock static methods (and utils classes)
and has to follow access rules of java to access your classes. There is another framework that can
be used in conjunction with this to mitigate this but I have not played with it yet.


Back to the top