1

I use Intellij IDEA 2016.3.1. This is my java code (rest assured library):

when().get("/users").then().statusCode(200).body("", is(empty()));

This is how I want it to be:

when()
     .get("/users")
.then()
     .statusCode(200)
     .body("", is(empty()));

But, Intellij IDEA only allows me to do only this:

when()
         .get("/users").then().statusCode(200).body("", is(empty()));

How do I fix it ?

ANSWER - https://sqa.stackexchange.com/questions/9781/auto-formatting-restassured-test-cases-in-my-ide

MasterJoe
  • 2,103
  • 5
  • 32
  • 58
  • 8
    Don't waste time fighting the code formatter. – Thilo Jan 12 '17 at 01:32
  • @Thilo - Does that mean I cannot format my code for better readability in Intellij IDEA ? – MasterJoe Jan 12 '17 at 01:33
  • 5
    How should it know not to indent `.then()`? – 4castle Jan 12 '17 at 01:33
  • 1
    I doubt it's possible without a custom formatter. – shmosel Jan 12 '17 at 01:34
  • 2
    @testerjoe2 It means you should format your code manually when you want a small piece of code to have different formatting. – 4castle Jan 12 '17 at 01:37
  • 1
    @4castle additionally it means you'd have to annotate that block of code to prevent auto-formatting when you do it at the file level - at least that's what you had to do for Eclipse, not sure if IntelliJ has an equivalent thing. – nevets1219 Jan 12 '17 at 01:43
  • 1
    @nevets1219 Yes, you can use annotations [like these](http://stackoverflow.com/a/19492318/5743988). – 4castle Jan 12 '17 at 01:47
  • @4castle - It does not work for me. http://stackoverflow.com/questions/3375307/how-to-disable-code-formatting-for-some-part-of-the-code-using-comments – MasterJoe Jan 12 '17 at 01:59
  • 1
    @testerjoe2 Sorry, that's not enough information for me to be of any help. – 4castle Jan 12 '17 at 02:02
  • @4castle - I put my code between off and on and I still cannot fix the formatting. – MasterJoe Jan 12 '17 at 02:03
  • 2
    Just use the ENTER and space keys. – Lew Bloch Jan 12 '17 at 02:05
  • @LewBloch - That works. But, I have to first remove the dot for the method call I want to move around, then move it using enter and space/tab and finally re insert the dot. – MasterJoe Jan 12 '17 at 02:08
  • I agree to *"How should it know not to indent .then() ?"* – JimHawkins Jan 13 '17 at 13:38
  • I've used all the major IDEs for Java, and not one needed one to remove the dot to format a line. – Lew Bloch Jan 13 '17 at 20:21
  • 1
    This question is answered here: https://sqa.stackexchange.com/questions/9781/auto-formatting-restassured-test-cases-in-my-ide – MKorsch Sep 02 '20 at 07:30
  • @MKorsch - Thanks ! Exactly what I needed. – MasterJoe Sep 04 '20 at 05:21
  • I’m voting to close this question because it already has an answer in another community (SQA). I have added a link to that answer in this question itself. But, please don't delete/hide this question. I am sure that people outside of SQA jobs would have this question too. – MasterJoe Sep 23 '20 at 23:53

0 Answers0