public class InspectingKt
| Modifier and Type | Method and Description |
|---|---|
static <K> void |
inspecting(K obj,
kotlin.jvm.functions.Function1<? super K,kotlin.Unit> inspector)
Inspecting allows to assert the properties of an object in a typed fashion providing a proper testing context.
|
public static <K> void inspecting(K obj,
kotlin.jvm.functions.Function1<? super K,kotlin.Unit> inspector)
Inspecting allows to assert the properties of an object in a typed fashion providing a proper testing context.
The simple example shows how inspecting can build up a assertion context making the tests more readable.
inspecting(person){
name shouldBe "John Doe"
age shouldBe 20
}
The elaborate example shows that inspecting can be used in a nested fashion in combination with other inspectors to simplify the property accesses.
inspecting(person){
name shouldBe "John Doe"
age shouldBe 20
forOne(friends){
inspecting(it){
name shouldBe "Samantha Rose"
age shouldBe 19
}
}
}
obj - the object that is being inspectedinspector - the inspector in which further assertions and inspections can be done