Skip to content

eq() argument matcher does not support for value class type arguments #544

@m-koops

Description

@m-koops

Observed with version 6.1.0

When verifying a function call on a mock with a value class type argument, the eq() argument matcher does not match.
This is demonstrated with the following test:

    @Test
    fun eq_forValueClass() {
        val valueClass = ValueClass("Content")
        mock<Methods>().apply {
            valueClass(valueClass)
            verify(this).valueClass(eq(valueClass))
        }
    }

This test fails with the message:

Argument(s) are different! Wanted:
methods.valueClass-T-UsNSA(
    ValueClass(content=Content)
);
-> at test.MatchersTest.eq_forValueClass(MatchersTest.kt:354)
Actual invocations have different arguments:
methods.valueClass-T-UsNSA(
    "Content"
);
-> at test.MatchersTest.eq_forValueClass(MatchersTest.kt:353)

In extend to #522, the MR that added value class support to the any() and anyOrNull() implementations, also eq() should be enhanced to support value class arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions