Versions Compared

Key

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

FEST Assertions Module has moved to Github !

Check this page :https://github.com/alexruiz/fest-assert-2.x/wiki

The documentation below is for Fest 1.x which is no more maintained, we are focusing our effort to the 2.x version !

....

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).

...

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();