Message Boards

can't Inject Service Components into Test class, it's null

mohamed elsisi, modified 2 Years ago.

can't Inject Service Components into Test class, it's null

New Member Post: 1 Join Date: 7/14/21 Recent Posts

I followed this article to inject the service component into my test class to  use it, but the component is always null 

public class ContactRequestLocalServiceImplTest {

    @Inject(type = com.linkdev.contactus.service.impl.ContactRequestLocalServiceImpl.class)
    private static ContactRequestLocalService _contactRequestLocalService;


    @ClassRule
    @Rule
    public static final AggregateTestRule aggregateTestRule =
            new LiferayIntegrationTestRule();


    @Test
    public void test01() {
        System.err.println(_contactRequestLocalService);  // this prints null 
    }
}