Maven is unable to successfully run my JUnit tests though they are being run without any problem on my Eclipse. I'm unable to solve it from the debug messages.
It is probably something to do with the Spring config because my other JUnit tests not relying on Spring are working fine.
Adding the surefire plugin forkMode as Always didn't work either.
Maven output
mvn install ... ... [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ AppServer --- [INFO] Surefire report directory: C:..\surefire-reports
Running com.ws.impl.BrowserServiceImplTest Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< FAILURE!
Failed tests: com.ws.impl.BrowserServiceImplTest.testGetStatuses()
com.ws.impl.BrowserServiceImplTest.testGetSellers()
Test class
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:test-context.xml")
public class BrowserServiceImplTest {
@Autowired
private BrowserServiceImpl browserServiceImpl;
@Test
public void testGetStatuses() {
// test code
}
// more code
}
Surefire report
<failure type="java.lang.NullPointerException">java.lang.NullPointerException
at com.ws.impl.BrowserServiceImplTest.testGetStatuses(BrowserServiceImplTest.java:48)
</failure>
Edit
Lines 48-49
List<String> statuses = browserServiceImpl.getStatuses();
assertEquals(12, statuses.size());
Edit 2
test-context.xml
<bean id="browserSvc" class="com.ws.impl.BrowserServiceImpl">
<property name="filterOptionsService" ref="filterOptionsService" />
</bean>
BrowserServiceImpl.java
@WebService(targetNamespace = "http://abc.def.com", portName = "BrowserPort", serviceName = "BrowserService")
public class BrowserServiceImpl implements BrowserService {
private FilterOptionsService filterOptionsService;
// more code
}