Injector created twice (or more)

4 views
Skip to first unread message

Jordi Gerona

unread,
Apr 2, 2009, 12:24:29 PM4/2/09
to atunit
hey there!

good job with AtUnit, it's a nice testing framework to use along with
guice for integration tests. primarily i use it for integration that
and mocking.

the problem comes that i use a module to start the persistence service
(using warp), and the injector is created for every @Test in the
class. for each test, the database connection and all that kind of
stuff is initialized, making the overall test goes slower.

i mean, the injector is created like i was using a @Before annotation,
and not @BeforeClass. is it possible to do that? just initialize one
time the injector? am i doing something strange?

thanks!

jordi

Guðmundur Bjarni

unread,
Apr 3, 2009, 12:21:54 PM4/3/09
to atunit
Hello Jordi,

The injector is created for every test in your test class, like it's
done with @Before, to have a clean slate for every test. Of course it
would be faster if it was done per test class. But then each test has
to be aware of that it's sharing state with the other tests, and a
failing test might be failing because of something a previous test
case did.

regards,
Guðmundur Bjarni

jordi

unread,
Apr 6, 2009, 3:38:37 AM4/6/09
to atu...@googlegroups.com
that's exactly what i thought, but it could be some kinda option if you wanna boost your tests speed.

Another project that you probably know, Guiceyfruit, creates the Injector per test class...

btw, thanks for the answer!

2009/4/3 Guðmundur Bjarni <gudmundu...@gmail.com>
Reply all
Reply to author
Forward
0 new messages