public class ReflectionKt
| Modifier and Type | Method and Description |
|---|---|
static <T> Matcher<T> |
beEqualToIgnoringFields(T other,
kotlin.reflect.KProperty fields)
Matcher that compares values without using specific fields
|
static <T> Matcher<T> |
beEqualToUsingFields(T other,
kotlin.reflect.KProperty fields)
Matcher that compares values using specific fields
|
static <T> void |
shouldBeEqualToIgnoringFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is equal to other without using specific fields
|
static <T> void |
shouldBeEqualToUsingFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is equal to other using specific fields
|
static <T> void |
shouldNotBeEqualToIgnoringFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is not equal to other without using specific fields
|
static <T> void |
shouldNotBeEqualToUsingFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is NOT equal to other using specific fields
|
public static <T> void shouldBeEqualToUsingFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is equal to other using specific fields
Verifies that this instance is equal to other using only some specific fields. This is useful for matching on objects that contain unknown values, such as a database Entity that contains an ID (you don't know this ID, and it doesn't matter for you, for example)
Opposite of ReflectionKt.shouldNotBeEqualToUsingFields
Example:
data class Foo(val id: Int, val description: String)
val firstFoo = Foo(1, "Bar!")
val secondFoo = Foo(2, "Bar!")
firstFoo.shouldBeEqualUsingFields(secondFoo, Foo::description) // Assertion passes
firstFoo shouldBe secondFoo // Assertion fails, `equals` is false!
public static <T> void shouldNotBeEqualToUsingFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is NOT equal to other using specific fields
Verifies that this instance is not equal to other using only some specific fields. This is useful for matching on objects that contain unknown values, such as a database Entity that contains an ID (you don't know this ID, and it doesn't matter for you, for example)
Opposite of ReflectionKt.shouldBeEqualToUsingFields
Example:
data class Foo(val id: Int, val description: String)
val firstFoo = Foo(1, "Bar!")
val secondFoo = Foo(2, "BAT")
firstFoo.shouldNotBeEqualToUsingFields(secondFoo, Foo::description) // Assertion passes
public static <T> Matcher<T> beEqualToUsingFields(T other, kotlin.reflect.KProperty fields)
Matcher that compares values using specific fields
Verifies that two instances not equal using only some specific fields. This is useful for matching on objects that contain unknown values, such as a database Entity that contains an ID (you don't know this ID, and it doesn't matter for you, for example)
Example:
data class Foo(val id: Int, val description: String)
val firstFoo = Foo(1, "Bar!")
val secondFoo = Foo(2, "Bar!")
firstFoo should beEqualToUsingFields(secondFoo, Foo::description) // Assertion passes
public static <T> void shouldBeEqualToIgnoringFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is equal to other without using specific fields
Verifies that this instance is equal to other without using some specific fields. This is useful for matching on objects that contain unknown values, such as a database Entity that contains an ID (you don't know this ID, and it doesn't matter for you, for example)
Opposite of ReflectionKt.shouldNotBeEqualToIgnoringFields
Example:
data class Foo(val id: Int, val description: String)
val firstFoo = Foo(1, "Bar!")
val secondFoo = Foo(2, "Bar!")
firstFoo.shouldBeEqualToIgnoringFields(secondFoo, Foo::id) // Assertion passes
firstFoo shouldBe secondFoo // Assertion fails, `equals` is false!
public static <T> void shouldNotBeEqualToIgnoringFields(T $receiver,
T other,
kotlin.reflect.KProperty properties)
Asserts that this is not equal to other without using specific fields
Verifies that this instance is not equal to other without using some specific fields. This is useful for matching on objects that contain unknown values, such as a database Entity that contains an ID (you don't know this ID, and it doesn't matter for you, for example)
Opposite of ReflectionKt.shouldBeEqualToIgnoringFields
Example:
data class Foo(val id: Int, val description: String)
val firstFoo = Foo(1, "Bar!")
val secondFoo = Foo(2, "BAT!")
firstFoo.shouldNotBeEqualToIgnoringFields(secondFoo, Foo::id) // Assertion passes
public static <T> Matcher<T> beEqualToIgnoringFields(T other, kotlin.reflect.KProperty fields)
Matcher that compares values without using specific fields
Verifies that two instances are equal by not using only some specific fields. This is useful for matching on objects that contain unknown values, such as a database Entity that contains an ID (you don't know this ID, and it doesn't matter for you, for example)
Example:
data class Foo(val id: Int, val description: String)
val firstFoo = Foo(1, "Bar!")
val secondFoo = Foo(2, "Bar!")
firstFoo should beEqualToIgnoringFields(secondFoo, Foo::id) // Assertion passes