/** This method tests the {@code hasNumberOfColumnsLessThan} assertion method. */ @Test public void test_has_number_of_columns_less_than() { WritableAssertionInfo info = new WritableAssertionInfo(); Table table = new Table(); TableAssert tableAssert = assertThat(table); TableAssert tableAssert2 = AssertionsOnNumberOfColumns.hasNumberOfColumnsLessThan(tableAssert, info, 3, 4); Assertions.assertThat(tableAssert2).isSameAs(tableAssert); }
/** This method should fail because the number of columns is equal. */ @Test public void should_fail_because_number_of_columns_is_equal() { WritableAssertionInfo info = new WritableAssertionInfo(); info.description("description"); Table table = new Table(); TableAssert tableAssert = assertThat(table); try { AssertionsOnNumberOfColumns.hasNumberOfColumnsLessThan(tableAssert, info, 3, 3); fail("An exception must be raised"); } catch (AssertionError e) { Assertions.assertThat(e.getMessage()) .isEqualTo( String.format( "[description] %n" + "Expecting size (number of columns) to be less than :%n" + " <3>%n" + "but was:%n" + " <3>")); } }