I have working JUnit tests for my MVC controllers. Now I wanted to display the build number in the footer of every page, so I added the following div in my thymeleaf templates:
<div class="versionInfo">Version <span th:text="${@buildProperties.getVersion()}"></span></div>
Now the test fail with:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'buildProperties' available
I tried to add it as a mock to no avail:
@MockBean
private BuildProperties buildProperties;
Or following this advice (see my comment below the answer).
So how can I make my tests work again with the BuildProperties
?