Jukito has 5 main features
- taking care of the boiler plate code to create the injector.
- introducing a new scope "TestSingleton" which is similar to Singleton
except that it is cleared after each test method. So you get a fresh
instance for the every test method but within the test method the
instance is a singleton.
- allowing to inject dependencies into methods annotated with @Test,
@Before, @After (I'm not sure about @BeforeClass and @AfterClass).
- creating Mockito mocks for any unbound dependency (this feature can be
disabled).
- providing the possibility to bind multiple instances or
implementations (similar to SetBinder). A test method is then executed
once for every bound instance/implementation.
I personally try to avoid DI in unit tests. But for some integration
tests it comes handy. In these cases I like to use Jukito since it
reduces the lines of code in the test notably.
On 10/29/2014 08:04 PM, Kevin Burton wrote:
Yes. I think I'm going to back out the ImplementedBy support in a few
weeks. Long story but it requires some refactoring.
And I couldn't wrap my head around Jukito but maybe I need to spend
some time on it.
I guess it just auto-creates mocks for me.
Kevin
On Tuesday, October 28, 2014 11:22:50 PM UTC-7, scl wrote:
Yes, you don't want to have dependencies on your test code.
If all you need is injection of mocks then you may want to look at
jukito as it can inject mocks for any dependency for which you
havn't bound an implementation.
Am 29.10.2014 02:52 schrieb Sam Berlin <sbe...@gmail.com
<javascript:>>:
@ImplementedBy is generally a bad idea because it forces your
API to have a dependency on your implementation. @MockedBy
would be even worse, because it would force your API to have a
dependency on your tests.
If you're looking to make testing mocked bindings easier, see
https://github.com/google/guice/wiki/BoundFields
<https://github.com/google/guice/wiki/BoundFields>, new in
Guice 4.0.
sam
On Tue Oct 28 2014 at 7:01:31 PM Kevin Burton
<burto...@gmail.com <javascript:>> wrote:
@ImplementedBy is handy because I can have the reference
implementation defined in the interface.
But for tests, I have to manually create bindings.
I wonder if something similar is needed for mocks. Maybe
a @MockedBy ?
Or maybe it's a bad idea :-P
--
You received this message because you are subscribed to
the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to google-guice...@googlegroups.com
<javascript:>.
To post to this group, send email to
google...@googlegroups.com <javascript:>.
Visit this group at
http://groups.google.com/group/google-guice
<http://groups.google.com/group/google-guice>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/cb2a65d0-24cb-4c7f-93ea-3655d5dafdc1%40googlegroups.com
<https://groups.google.com/d/msgid/google-guice/cb2a65d0-24cb-4c7f-93ea-3655d5dafdc1%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the
Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to google-guice...@googlegroups.com
<javascript:>.
To post to this group, send email to
google...@googlegroups.com <javascript:>.
Visit this group at
http://groups.google.com/group/google-guice
<http://groups.google.com/group/google-guice>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/CAJEBNUc88JxpeTyoj64NcK2JBhn%3DqwHdoSk8LtFfXTuV1k3R2w%40mail.gmail.com
<https://groups.google.com/d/msgid/google-guice/CAJEBNUc88JxpeTyoj64NcK2JBhn%3DqwHdoSk8LtFfXTuV1k3R2w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google
Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to google-guice+unsubscr...@googlegroups.com
<mailto:google-guice+unsubscr...@googlegroups.com>.
To post to this group, send email to google-guice@googlegroups.com
<mailto:google-guice@googlegroups.com>.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/4d943869-9ed6-409c-870f-cdf0389f4f54%40googlegroups.com
<https://groups.google.com/d/msgid/google-guice/4d943869-9ed6-409c-870f-cdf0389f4f54%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/5451DD9C.2090101%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.