assertj / doc

AssertJ new website

Home Page:https://assertj.github.io/doc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document migration path from single array to 2D array assertions introduced in 3.17.0

mipper opened this issue · comments

Summary

The hasSize(int) method is no longer available on 2D arrays after commit assertj/assertj@a36275e which was released as part of 3.17.0.

I have no idea whether other methods have also become unavailable on this, not whether other array classes are affected.

Example

This test will compile under 3.16.1 but not on any version after that up to 3.18.1.

package org.asserj;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class HasSizeTest
{
    @Test
    public void shouldAnswerWithTrue()
    {
        assertThat(new String[][] { { "1" } }).hasSize(1);
    }
}

@mipper the introduction of 2D array assertions in 3.17.0 is mentioned as a breaking change.

In the example, hasSize(1) should be replaced with hasDimensions(1, 1).

I saw the release notes, but they don't list any methods that have been removed. It's a shame they're not listed along with the methods which should replace them.

@mipper fair enough, would you mind improving the release notes for other users?

Hi , i would like to work on this issue

This section could be enhanced with a mapping between old and new assertions in case of two-dimensional arrays:

Assertion before 3.17.0 Assertion after 3.17.0
contains(ELEMENT, Index) contains(ELEMENT[], Index)
doesNotContain(ELEMENT, Index) doesNotContain(ELEMENT[], Index)
hasSameSizeAs(Object) hasSameDimensionsAs(Object)
hasSize(int) hasDimensions(int, int)
isEmpty() isEmpty()
isEqualTo(Object) isEqualTo(Object)
isNotEmpty() isNotEmpty()
isNullOrEmpty() isNullOrEmpty()

We could also mention that the remaining assertions do not have a replacement and we are happy to receive feature requests if there is a use case for any of them.