Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Here's a list of find/replace based on regexp that allow to change JUnit assertion into FEST assertion (don't forget to check regexp mode in your editor replace window).

A similar idea would be to use the Structured Search and Replace (SSR) feature of IntelliJ IDEA.

Note that FEST & JUnit assertions can coexist together, you don't have to migrate all in one time.

Changing

Wiki Markup
{highlight:yellow}{*}assertEquals(0, myList.size())*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(myList).isEmpty()*{highlight}

Code Block
assertEquals(0,(.*).size()); -> assertThat(\1).isEmpty();

It's important to run this one before the assertEquals -> isEqualTo, to avoid ending with : assertThat(myList.size()).isEqualTo(0)

Changing

Wiki Markup
{highlight:yellow}{*}assertEquals(expectedSize, myList.size())*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(myList).hasSize(expectedSize)*{highlight}

Code Block
assertEquals((.*),(*.).size()); -> assertThat(\2).hasSize(\1);

It's important to run this one before the assertEquals -> isEqualTo, to avoid ending with : assertThat(myList.size()).isEqualTo(expectedSize)

Changing

Wiki Markup
{highlight:yellow}{*}assertEquals(value, valueUnderTest)*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(valueUnderTest).isEqualTo(value)*{highlight}

Code Block
assertEquals((.),(.)); -> assertThat(\2).isEqualTo(\1);

Changing

Wiki Markup
{highlight:yellow}{*}assertNotEquals(value, valueUnderTest)*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(valueUnderTest).isNotEqualTo(value)*{highlight}

Code Block
assertNotEquals((.),(.)); -> assertThat(\2).isNotEqualTo(\1);

Changing

Wiki Markup
{highlight:yellow}{*}assertNull(objectUnderTest)*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(objectUnderTest).isNull()*{highlight}

Code Block
assertNull((.*)); -> assertThat(\1).isNull();

Changing

Wiki Markup
{highlight:yellow}{*}assertNotNull(objectUnderTest)*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(objectUnderTest).isNotNull()*{highlight}

Code Block
assertNotNull((.*)); -> assertThat(\1).isNotNull();

Changing

Wiki Markup
{highlight:yellow}{*}assertTrue(logicalCondition)*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(logicalCondition).isTrue()*{highlight}

Code Block
assertTrue((.*)); -> assertThat(\1).isTrue();

Changing

Wiki Markup
{highlight:yellow}{*}assertFalse(logicalCondition)*{highlight}
to
Wiki Markup
{highlight:yellow}{*}assertThat(logicalCondition).isFalse()*{highlight}

Code Block
assertFalse((.*)); -> assertThat(\1).isFalse();