LeakCanaryConfigTest.kt
TLDR
The provided file LeakCanaryConfigTest.kt
contains a test class LeakCanaryConfigTest
that validates the fields in LeakCanary.Config
against the corresponding builder functions in LeakCanary.Config.Builder
.
Methods
LeakCanaryConfigTest()
This method is the constructor of the LeakCanaryConfigTest
class.
LeakCanaryConfigTest.builderMatchesConfig()
This method is the test method that validates that each field in LeakCanary.Config
has a matching builder function in LeakCanary.Config.Builder
.
configBuilderFunctions()
This private method returns a list of names of the builder functions in LeakCanary.Config.Builder
.
configProperties()
This private method returns a list of names of the fields in LeakCanary.Config
.
package leakcanary
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import kotlin.reflect.full.memberFunctions
import kotlin.reflect.full.memberProperties
class LeakCanaryConfigTest {
/**
* Validates that each field in [LeakCanary.Config] has a matching builder function
* in [LeakCanary.Config.Builder]
*/
@Test fun `LeakCanary Config Builder matches LeakCanary Config`() {
assertThat(configProperties())
.containsExactlyInAnyOrderElementsOf(configBuilderFunctions())
}
private fun configBuilderFunctions() = LeakCanary.Config.Builder::class.memberFunctions
.map { it.name }
.subtract(setOf("build", "equals", "hashCode", "toString"))
private fun configProperties() = LeakCanary.Config::class.memberProperties
.map { it.name }
}