I need to create tests for some class. This class in main project (src/main/java/..
) is injected easily into another classes, since I have custom ResourceConfig class which declares which packages have to be scanned to seek for service classes.
Now I created test directories (in src/test/java/..
) and created a class, something like:
public class TheMentionedClassIntegrationTest {
@Inject
private TheMentionedClass theMentionedClass ;
@Test
public void testProcessMethod() {
assertNotNull(theMentionedClass);
}
}
But the problem is that whatever I do the class is always null. In another tests in the project I was using JerseyTest
class. So I tried to do the same here, extend TheMentionedClassIntegrationTest
with JerseyTest
, override configure
method, create my private ResourceConfig
class which registers Binder
(default for whole project) and register TheMentionedClassIntegrationTest
as well.
It didnt work. I did many different attempts but none of them were successfull. I think working with HK2
is extremly difficult, there is no good documentation or so..
Do you guys have an idea how to inject TheMentionedClass into the test class? Maybe my approach is wrong?
Thanks!
Aucun commentaire:
Enregistrer un commentaire