Auto-formatting RestAssured test cases in my IDE



  • We have our tests implemented in RestAssured, using nice and readable convention of indentation for given/when/then parts. given(). param("key1", "value1"). param("key2", "value2"). when(). post("/somewhere"). then(). body(containsString("OK")); However, when I apply automatic formatting with template (Google code style for Java) in Intellij IDEA, the formatting I had gets destroyed. given(). param("key1", "value1"). param("key2", "value2"). when(). post("/somewhere"). then(). body(containsString("OK")); Is there a way my IDE or maven formats RestAssured statements with expected indentations, while the rest keeps with respect to the Google template? Or at least, it doesn't destroy what I have set for RestAssured statements?



  • A solution I found so far it to turn off formatting for certain sections, so that IDE does not destroy that. In Intellij Surround the code fragment with // @formatter:off ... // @formatter:on Preferences -> Code Style -> General -> Formatter Control -> Enable formatter markers in comments This does not auto-format RestAssured section, but at least does not destroy it.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2