Hello Daniel,

Daniel Watford <d...@foomoo.co.uk> writes:

> I don't have a preference between the two mocking libraries, but creating
> unit tests for MacroFormRenderer necessitates mocking static methods.
> Mockito doesn't offer static method mocking, but JMockit does.
> [...]
> To provide unit tests for MacroFormRenderer without using a mocking library
> like JMockit will require the class to be refactored which I deemed a bit
> of a risky change at this point, particularly without existing tests to
> prove correct behaviour is maintained.

Any effort that take into account how things can effectively be tested
is a good thing for OFBiz. :-)

My impression is that the "need" to mock static methods is a symptom of
entangled code. And that making the code simpler and better designed
will remove that need.  As you said having to refactor without tests in
the first place is not good but usage of advanced mocking techniques to
workaround the fact that basic unit testing is too hard is not ideal
neither.

Another solution (that is not ideal neither) is to rely on manual
testing in the first place (or automatic integration tests if you have
time) introduce the architectural refactoring and then add you unit test
with explicit arguments based dependency injection instead of mocks.

In any case that is a matter of compromise. :-)

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

Reply via email to