AppFuseEasyMock |
|
Your trail: |
Difference between
version 4
and
version 2:
At line 193 changed 1 line. |
I think this form of mocking your test is very simple to understand. The MockControl simply keeps track of the calls you make to the mocked instance. This way it becomes very easy to write down your expectations and the rather complicated setup of expectaions using bare Mocks is not needed anymore. Just like with bare Mocks you can set (void) return values or exceptions to be thrown. There are even convenience methods to specify that a method i supposed to be called n times. For more information on what EasyMock can do for you visit the EasyMock [Documentation|http://www.easymock.org/Documentation.html]. |
I think this form of mocking your test is very simple to understand. The MockControl simply keeps track of the calls you make to the mocked instance. This way it becomes very easy to write down your expectations and the rather complicated setup of expectations using bare Mocks is not needed anymore. Just like with bare Mocks you can set (void) return values or exceptions to be thrown. There are even convenience methods to specify that a method i supposed to be called n times. For more information on what EasyMock can do for you visit the EasyMock [Documentation|http://www.easymock.org/Documentation.html]. |
At line 206 changed 1 line. |
|
I consider Mocks to be a bit more than just a means of [White Box Tests|http://en.wikipedia.org/wiki/White_box_testing]. As the term itself indicates you need to have some knowlegde of the tested code in order to write a meaningful test. In contrast to [Black box Tests|http://en.wikipedia.org/wiki/Black_box_testing] where you don't care about the code itself, but only about the outcome of the test it will give you some information about the code you wrote. So, as a rule of thumb I belive that if you have difficulties writing a mock test for you business object that simply means your business object is designed badly. Therefore my paradigm concerning mock tests is simply:\\__"If you can't test it - refactor it!"__.\\Comments appreciated! |
Back to AppFuseEasyMock,
or to the Page History.
|