My service
@Service
public class StripeServiceImpl implements StripeService {
@Override
public int getCustomerId() {
return 2;
}
}
My test
public class StripeServiceTests {
@Autowired
StripeService stripeService;
@TestConfiguration
static class TestConfig {
@Bean
public StripeService employeeService() {
return new StripeServiceImpl();
}
}
@Test
public void findCustomerByEmail_customerExists_returnCustomer() {
assertThat(stripeService.getCustomerId()).isEqualTo(2);
}
}
The error: java.lang.NullPointerException. I had checked and the stripeService is actually null.