I'd like to create some tests that assert that thymeleaf templates will render given some context. I found I can do the following example, and it will yield the same result I get as when I call a web route.
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes={WebApp.class, H2JpaConfig.class})
@ActiveProfiles("test")
public class Foo {
@Autowired
SpringTemplateEngine templateEngine;
@Test
void letsTestThymeleaf(){
var context = new Context();
// add some variables
assertDoesNotThrow(() -> templateEngine.process("templateDirectory/some-template", context));
}
}
Now, this is a rather expensive thing as it starts the whole application, including database and webserver. Can I strip this down to just whatever the SpringTemplateEngine needs to do its job?