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

"propertiesAreEqualToIgnoring" does not work for some property names #266

Open
tmohme opened this issue May 11, 2022 · 0 comments
Open

"propertiesAreEqualToIgnoring" does not work for some property names #266

tmohme opened this issue May 11, 2022 · 0 comments

Comments

@tmohme
Copy link

tmohme commented May 11, 2022

The function is very useful but unfortunately Java introspection seems to have its own ideas about naming, so that properties are not ignored when their name starts with a lowercase letter immediately followed by an uppercase letter:

class PropertiesDemo {
    data class Bean(
        val lowercase: String,
        val camelCase: String,
        val bRoken: String,
    )
    val bean = Bean("bean", "bean", "bean")

    @Test
    fun camelCase() {
        val copied = bean.copy(camelCase = "different")
        expectThat(copied).propertiesAreEqualToIgnoring(bean, Bean::camelCase)
    }

    @Test
    fun lowerCase() {
        val copied = bean.copy(lowercase = "different")
        expectThat(copied).propertiesAreEqualToIgnoring(bean, Bean::lowercase)
    }

    @Test
    fun bRoken() {
        val copied = bean.copy(bRoken = "different")
        expectThat(copied).propertiesAreEqualToIgnoring(bean, Bean::bRoken)
    }
}

When you run the above tests, you'll find that strikt sees the property Bean::bRoken as "BRoken" and therefore does not ignore it and fails the test.

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

No branches or pull requests

1 participant