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

7 views
Skip to first unread message

Nguyen Viet

unread,
Mar 28, 2021, 4:35:18 AM3/28/21
to bndtools-users
Hi,

The issue I am facing now is when i run unit tests for my bnd projects, it runs successfully in Eclipse. But when i run with gradle build command, then i face this issue:

fi.mipro.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
Reply all
Reply to author
Forward
0 new messages