I am new to Spring Boot and testing. I am currently studying from baeldung's tutorial (https://spring.io/guides/gs/testing-web/) and I bumped into this error.
In fact, it passes when I use isNull() method. But I don't understand this because my controller class has mappings and all that. Why would it be null?
This is my controller class
Or maybe this is not how this test is supposed to be done? But they show it as follows in baeldung
Any help is appreciated.
Best,



If you want to run the testcases with spring context you need to provide
@SpringBootTestannotation at your test class (i.e instead of@SpringBootConfigurationat your test classSmoke). The other option apart from@SpringBootTestare as below.for junit4:
for junit 5:
Where
SpringTestConfigurationclass hold's all the beans you need to autowire. For more details of SpringRunner vs SpringBootTest read the article