Best Kluent code snippet using org.amshove.kluent.EquivalencyAssertionOptions.excluding
Equivalency.kt
Source:Equivalency.kt  
...79                return false80            } else if (subA != null && subB != null) {81                if (subA is Iterable<*>) {82                    if ((currentLevelOfRecursion == equivalencyAssertionOptions.maxLevelOfRecursion && !equivalencyAssertionOptions.allowingInfiniteRecursion)83                        || equivalencyAssertionOptions.excludingNestedObjects84                    ) {85                        return true86                    }87                    val actualList = subA.toList()88                    val expectedList = (subB as Iterable<*>).toMutableList()89                    if (actualList.size != expectedList.size) {90                        return false91                    }92                    for (i in actualList.indices) {93                        for (j in expectedList.indices) {94                            if (expectedList.size > j) {95                                equivalencyAssertionOptions.includedProperties.clear()96                                equivalencyAssertionOptions.excludedProperties.clear()97                                val deepEquals = areEquivalent(98                                    currentLevelOfRecursion,99                                    actualList[i]!!,100                                    expectedList[j]!!,101                                    equivalencyAssertionOptions102                                )103                                if (deepEquals) {104                                    expectedList.removeAt(j)105                                }106                            }107                        }108                    }109                    for (i in expectedList.indices) {110                        equivalencyAssertionOptions.includedProperties.clear()111                        equivalencyAssertionOptions.excludedProperties.clear()112                        val deepEquals = areEquivalent(113                            currentLevelOfRecursion,114                            actualList[i]!!,115                            expectedList[i]!!,116                            equivalencyAssertionOptions117                        )118                        if (!deepEquals) {119                            return false120                        }121                    }122                } else {123                    if ((currentLevelOfRecursion == equivalencyAssertionOptions.maxLevelOfRecursion && !equivalencyAssertionOptions.allowingInfiniteRecursion)124                        || equivalencyAssertionOptions.excludingNestedObjects125                    ) {126                        return true127                    }128                    equivalencyAssertionOptions.includedProperties.clear()129                    equivalencyAssertionOptions.excludedProperties.clear()130                    if (!areEquivalent(currentLevelOfRecursion, subA, subB, equivalencyAssertionOptions)) {131                        return false132                    }133                }134            }135        }136    }137    return true138}...EquivalencyAssertionOptions.kt
Source:EquivalencyAssertionOptions.kt  
...4    init {5        compareByProperties()6    }7    private var _compareByProperties: Boolean = true8    private var _excludingNestedObjects: Boolean = false9    private var _allowingInfiniteRecursion: Boolean = false10    private var _maxLevelOfRecursion = 1011    private var _withStrictOrdering: Boolean = false12    internal var compareByProperties13        get() = _compareByProperties14        private set(value) {15            _compareByProperties = value16        }17    internal val includedProperties: MutableList<KProperty1<*, *>> = mutableListOf()18    internal val excludedProperties: MutableList<KProperty1<*, *>> = mutableListOf()19    internal var excludingNestedObjects20        get() = _excludingNestedObjects21        private set(value) {22            _excludingNestedObjects = value23        }24    internal var allowingInfiniteRecursion25        get() = _allowingInfiniteRecursion26        private set(value) {27            _allowingInfiniteRecursion = value28        }29    internal var maxLevelOfRecursion30        get() = _maxLevelOfRecursion31        internal set(value) {32            _maxLevelOfRecursion = value33        }34    internal var withStrictOrdering35        get() = _withStrictOrdering36        private set(value) {37            _withStrictOrdering = value38        }39    fun compareByProperties(): EquivalencyAssertionOptions {40        compareByProperties = true41        return this42    }43    fun notCompareByProperties(): EquivalencyAssertionOptions {44        compareByProperties = false45        return this46    }47    fun excluding(property: KProperty1<*, *>): EquivalencyAssertionOptions {48        excludedProperties.add(property)49        return this50    }51    fun including(property: KProperty1<*, *>): EquivalencyAssertionOptions {52        includedProperties.add(property)53        return this54    }55    fun excludingNestedObjects(): EquivalencyAssertionOptions {56        excludingNestedObjects = true57        return this58    }59    fun allowingInfiniteRecursion(): EquivalencyAssertionOptions {60        allowingInfiniteRecursion = true61        return this62    }63    fun withStrictOrdering(): EquivalencyAssertionOptions {64        withStrictOrdering = true65        return this66    }67}...excluding
Using AI Code Generation
1val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = listOf ( "size" ) )2val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = { it . size } )3val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = { it . size ; it . size } )4val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = { it . size ; it . size } )5val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = { it . size ; it . size } )6val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = { it . size ; it . size } )7val expected = listOf ( 1 , 2 , 3 ) val actual = listOf ( 1 , 2 , 3 , 4 ) actual . shouldNotBeEqualTo ( expected , excluding = { it . size ; it . size } )Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
