Formatting of tests

When running the plugin on my spring project it’s creating tests for my classes. However, when I come to run them I get the following message:

Failed to execute goal io.spring.javaformat:spring-javaformat-maven-plugin:0.0.22:validate (default) on project spring-petclinic: Formatting violations found in the following files:
* $PATH/to/NewTest.java
Run `spring-javaformat:apply` to fix.

Is there something that can be done to generate tests that conform to the style of the project? Are there some settings I can configure to avoid this issue? I’m sure you can imagine this is quite annoying on large projects.

Hey pcrane,

Yeah I’ve seen that on some of my projects as well. The tests that the plugin writes don’t necessarily stick to the code style you have in force. I find it doesn’t really bother me while I’m using IntelliJ, because running the tests inside IntelliJ doesn’t actually call mvn test, so it doesn’t complain about the formatting.

Of course, when I do actually run mvn test (like when I push to CI), then it shouts at me, but all I have to do is:
mvn spring-javaformat:apply
(as suggested by the maven output), and voilà! I have now integrated it as part of my normal workflow because, to be honest, I’m not that good at sticking to the format myself, but it would be amazing if the plugin did it by itself. I think I’ll send Diffblue a feature request.