Improve entire core or module with IntelliJ structural replace

Actually this laziness is backfiring. I am so excited about structural replacements that I keep finding new challenges :joy:

For example assertions like

assertTrue(program.getStates().size() == 1);

Are better written as

assertThat(program.getStates(), hasSize(1));

So in case the size is not equal to one I do not only get an error message saying you wanted the expression to be true but it was false. Instead I want to see the actual size of the collection in this case. Or the actual value vs my expected one.

So I did

The beauty of it is that it also highlights the match while you edit the search template :slight_smile: You can also replace old try/catch JUnit 3 style exception testing with assertThrows (see) which is very helpful for module devs migrating to JUnit 5 :ok_hand:

2 Likes