--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
I'm doing quite a lot of groovy these days. Many times I still create
explicit constructors even though groovy has language support for
map-based constructors & has getters & setters for free.
If I'm keen on forcing constructor injection from tests in java, I
would do something like:
class MyTest {
@Mock Foo foo
@Mock Bar bar
Service service = new Service(foo, bar);
// then the test methods
Since JUnit instantiates fields per each test method we don't need
@Before method. That's pretty much what you have in your blog :)
Cheers!
--
Szczepan Faber
Principal engineer@gradleware
Lead@mockito
It's not a killer feature, no doubt. Yet, you don't even know how many
people are excited about it :) I'm OK with multiple ways of achieving
the goal so the annotations do not bother me too much. Annotations
tend to stick out better in a test and hence (arguably) readability
increases a bit.
@InjectMocks falls back to reflection which is something some people appreciate.
Cheers!