Skip to content

Property introspection not able to identify record accessors #3539

@JaspreetSinghJassal

Description

@JaspreetSinghJassal
  • assertj core version: 3.26.3
  • java version: 21
  • test framework version: junit-jupiter-api 5.9.3

Test case reproducing the bug

    private record DummyRecord(String name, int revision) {

        //This is the culprit, as the naming seems to affect assertJ's internal reflection-logic. Comparison works as expected when I rename this method to anything different. 
        public boolean isRevision() {
            return revision != 1;
        }
    }

    @Test public void recursiveComparison_javaRecords() {
        assertThat(new DummyRecord("Bob", 10)).usingRecursiveComparison().isEqualTo(new DummyRecord("Bob", 2)); //passes, but should fail
    }

Metadata

Metadata

Labels

language: Java 17+An issue related to using AssertJ with Java 17 or newertheme: recursive comparisonAn issue related to the recursive comparison

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions