I am using spring boot 1.4,
when using the @SpringBootTest annotation for integration test, it gives a null pointer.
@RunWith(SpringRunner.class);
@SpringBootTest
public class MyControllerTest {
@Test
public void mytest {
when().
get("/hello").
then().
body("hello");
}
}
and for main class:
@SpringApplication
@EnableCaching
@EnableAsync
public class HelloApp extends AsyncConfigureSupport {
public static void main(String[] args) {
SpringApplication.run(HelloApp.class, args);
}
@Override
public Executor getAsyncExecutor() {
...
}
}
Then in my controller:
@RestController
public class HelloController {
@Autowired
private HelloService helloService;
@RequestMapping("/hello");
public String hello() {
return helloService.sayHello();
}
}
HelloService
@Service
public class HelloService {
public String sayHello() {
return "hello";
}
}
But it ways says NullPointException when for helloService when processing request.
What am I missing?