News for hackers. Stuff that matters.
Re:Better Java – Resources for Writing Modern Java by lmm on Sunday September 20, 2015 @03:32AM (#10246842)
jMock isn't great, but Mockito makes it too hard to understand which method you haven't stubbed; I find EasyMock with its explicit replay() step much easier.
Re:Better Java – Resources for Writing Modern Java by twic on Sunday September 20, 2015 @10:24AM (#10247602)
I rather like Moxie for mocking:

https://github.com/pobrelkey/moxiemocks

Re:Better Java – Resources for Writing Modern Java by cam- on Sunday September 20, 2015 @03:47PM (#10248758)
JMock at least blows up if you don't mock something. Powermock and Mockito will let it pass. It is a shame JMock's API is so wordy.
Re:Better Java – Resources for Writing Modern Java by mabbo on Monday September 21, 2015 @02:18PM (#10254130)
That's what I hate about JMock, lol.

You had better mock everything, and better put them in the exact order they will occur in, or your test fails.

Most JMock unit tests I see are essentially the exact same code as is being tested, written a second time in the unit test. So if I want to refactor or modify this code in any way, my unit tests break- even if functionally, my tests are doing exactly what their spec says.

With Mockito, I can say 'Hey, if anyone calls this method with parameters sort of like this, give them this response', and then focus on my unit tests actually testing the output for a given input.

Re:Better Java – Resources for Writing Modern Java by lmm on Sunday September 20, 2015 @04:29PM (#10248942)
Like I said, Easymock. Powermock has an Easymock API too if you need the mocking statics/object creation.
Re:Better Java – Resources for Writing Modern Java by mabbo on Monday September 21, 2015 @02:15PM (#10254103)
Eesh, let's agree to disagree. EasyMock has some advantages, but I find the readability of Mockito outweighs them.