-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove robolectric deprecated override (#18)
- Loading branch information
Showing
4 changed files
with
50 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...android/src/main/kotlin/br/com/colman/kotest/android/extensions/robolectric/Extensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package br.com.colman.kotest.android.extensions.robolectric | ||
|
||
import java.lang.reflect.Field | ||
import java.lang.reflect.Type | ||
|
||
internal fun Class<*>.getField(fieldClass: Type): Field { | ||
return declaredFields.firstOrNull { it.type == fieldClass } | ||
?: throw IllegalStateException("Not found $fieldClass field.") | ||
} | ||
|
||
internal inline fun <reified T> Class<*>.getValue(obj: Any): T { | ||
val field = getField(T::class.java) | ||
field.isAccessible = true | ||
return field.get(obj) as T | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters