本来 bookService的引用一直是null。
导致每次测试都报空指针异常。
然后现在继承相应的 ApplicationTests类,然后使用@Component将该类注册为组件。就可以正常注入了。
ApplicationTests
@Component