rewrite-testing-frameworks icon indicating copy to clipboard operation
rewrite-testing-frameworks copied to clipboard

added recipe to collapse consecutive AssertThat statements (#373)

Open srmalkan opened this issue 2 years ago • 5 comments

Closes #373

Hi All,

I have added a recipe to collapse if consecutive AssertThat statements on the same parameter are found. It ignores cases where the parameter is a Method Invocation or lambda or existing chained assertThat statement.

I am facing a bit of difficulty in formatting the chained assertThat statement, can someone guide me on that?

srmalkan avatar Aug 01 '23 19:08 srmalkan

Really nice to see you picked this up @srmalkan! Impressed with how much of the recipe already works. I've explored locally if I could get the indentation to work, but no such luck yet either. I'd expected the fix to be in setting a prefix on each of the method invocations where we change the select, but I've not yet found a working combination. Will try to explore later again.

timtebeek avatar Aug 03 '23 12:08 timtebeek

Yes, i thought so too. After looking at few objects, now i feel its related to setting up 'after' correctly in JRightPadded.

srmalkan avatar Aug 03 '23 14:08 srmalkan

Hi @timtebeek,

I was able to fix formatting by setting after in the JRightPadded element. However, facing difficulty to set whitespace correctly.

srmalkan avatar Aug 06 '23 13:08 srmalkan

Glad to see how far this has come! I think we can just adjust the after values to include and additional level of indentation; That's the only remaining issue right?

timtebeek avatar Aug 07 '23 21:08 timtebeek

Glad to see how far this has come! I think we can just adjust the after values to include and additional level of indentation; That's the only remaining issue right?

That's correct.

srmalkan avatar Aug 09 '23 12:08 srmalkan