Unit test failed (java.lang.NullPointerException) when running with Gradle

Hi,

When i run unit tests for my gradle with bnd projects, it runs successfully in Eclipse. But when i run with gradle build command, then i face this issue:

fi.abc.ctc.chat.ChatClient.SetupTest > testReadLocalProperties FAILED
java.lang.NullPointerException at SetupTest.java:26

Here is the test:
@Test
public void testReadLocalProperties() throws Exception {
this.properties.load(Setup.class.getResourceAsStream(“ChatClient.properties”));
this.setup.readLocalProperties(this.properties);
assertNotNull(this.setup.getHostName());
assertNotNull(this.setup.getPortNumber());
assertNotNull(this.setup.getUseSSL());
if (this.setup.getHostName() == null) {
fail(“Hostname is null”);
}
}

So, the issue is it can not load the file: ChatClient.properties located under src/test/resources. Can you please help me what i should do to include src/test/resources during the testing.

Thank you so much!

Regards,
Viet

Hard to guess without more information. Can you provide an MCVE? src/test/resources is available during testing, but there can be a multitude of things you are hitting why it does not work. You should be able to use -d to see that it is added to the class path iirc.