I would like to check some/all templates during our unit tests. Does someone know a way already?
What I want to do is basically load a template and check if the syntax is correct. This should go that far that expressions are parsed, but not evaluated as I do not want to create a whole bunch of data just to check if the design is ok or not. The final test is done in Selenium anyway, but during a build it would be very nice to check if the developers do a good job :)
Re: Test Template for valid syntax during unit test?
It's supposed to be a quick fail to check if each html template is well balanced and that all expressions will be able to execute without a parseexception before we launch the extensive selenium tests. It's just a time safer in the end.
It's not that neccessary as we are able to develop the templates on the fly without redeployment already, so most of the parseexpression exceptions are directly solved during this period. It still happens frequently that a developer misses a quote or a brace in the first writing of the expression, even after one year ;)
I have already found a way to validate most of the expressions, but it involves quite some handling for the different expression types. I currently validate just simple expressions by taking the attribute value and call expressionparser.parse myself. This however does not work for iteration expressions nor "with" expressions without some upfront modification.
Do you know if there is a single point of entry to parse expressions in Thymeleaf?