Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isDataClassEqualTo passes when given different data objects #551

Open
VirtualParticle opened this issue Oct 24, 2024 · 0 comments · May be fixed by #552
Open

isDataClassEqualTo passes when given different data objects #551

VirtualParticle opened this issue Oct 24, 2024 · 0 comments · May be fixed by #552
Labels

Comments

@VirtualParticle
Copy link

This test should fail, but it passes:

data object Example
data object AnotherExample

@Test
fun test() {
    assertThat(Example).isDataClassEqualTo(AnotherExample)
}

When using a normal object, it does fail since they aren't data classes:

object Example
object AnotherExample

@Test
fun test() {
    assertThat(Example).isDataClassEqualTo(AnotherExample)
    /*
    only supports data classes
        java.lang.IllegalArgumentException: only supports data classes
    */
}

And the different data objects correctly fail when using isEqualTo:

data object Example
data object AnotherExample

@Test
fun test() {
    assertThat(Example).isEqualTo(AnotherExample)
    /*
    Expected :[Another]Example
    Actual   :[]Example

    org.opentest4j.AssertionFailedError: expected:<[Another]Example> but was:<[]Example>
    */
}

I'd expect this to fail similarly to using isEqualTo or with a message that they're not supported. The current behavior gives the impression of a passing test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants