title: Thymeleaf: Do not render during unit test?
body: <p>As I haven't gotten an answer for my other question <a href="https://stackoverflow.com/questions/54712564/webmvctest-does-not-find-buildproperties">here</a>, I am looking for another approach. Is there a way to no not execute or include a fragment during unit testing?</p>
  
  <p>I want to display the version and build number in the footer of my templates, thus I have the following line:</p>
  
  <pre><code>&lt;div class="versionInfo"&gt;Version &lt;span th:text="${@buildProperties.getVersion()}"&gt;&lt;/span&gt;&lt;/div&gt;
  </code></pre>
  
  <p>This works well when running the application, but during unit test I get the exception:</p>
  
  <blockquote>
    <p>No bean named 'buildProperties' available</p>
  </blockquote>
  
  <p>In the other question I am looking for a way to get this bean during unit test, as an alternative I am now looking for a way to exclude this template during unit tests. Something like this:</p>
  
  <pre><code>&lt;div class="versionInfo" th:if="${!isUnitTest}"&gt;Version &lt;span th:text="${@buildProperties.getVersion()}"&gt;&lt;/span&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I am using the following annotations on my test class:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @WebMvcTest(SimpleController.class)
  </code></pre>