-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Compose 1.7 + implement missing APIs for ComposeContext (#354)
* Update to Compose BOM * Add a unit test that verifies complete coverage of ComposeTestRule API for the JUnit 5 version * Add missing API methods from JUnit 4's ComposeTestRule to JUnit 5's ComposeContext * Update instrumentation/compose/src/main/java/de/mannodermaus/junit5/compose/ComposeContext.kt * Update instrumentation/compose/src/main/java/de/mannodermaus/junit5/compose/ComposeContext.kt * Update instrumentation/compose/src/test/java/de/mannodermaus/junit5/compose/ComposeContextTests.kt
- Loading branch information
1 parent
6a874bc
commit 0a5c122
Showing
9 changed files
with
124 additions
and
46 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
7 changes: 5 additions & 2 deletions
7
instrumentation/.idea/runConfigurations/Runner__Run_Unit_Tests__Gradle_.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 6 additions & 2 deletions
8
instrumentation/.idea/runConfigurations/Sample__Run_Unit_Tests__Gradle_.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
31 changes: 31 additions & 0 deletions
31
instrumentation/compose/src/test/java/de/mannodermaus/junit5/compose/ComposeContextTests.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,31 @@ | ||
package de.mannodermaus.junit5.compose | ||
|
||
import androidx.compose.ui.test.junit4.ComposeContentTestRule | ||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
import org.junit.jupiter.api.Assertions.fail | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.MethodSource | ||
import java.lang.reflect.Method | ||
|
||
class ComposeContextTests { | ||
companion object { | ||
@JvmStatic | ||
fun relevantMethods() = buildList { | ||
addAll(ComposeTestRule::class.java.relevantMethods) | ||
addAll(ComposeContentTestRule::class.java.relevantMethods) | ||
} | ||
|
||
private val <T> Class<T>.relevantMethods | ||
get() = declaredMethods.filter { '$' !in it.name } | ||
} | ||
|
||
@MethodSource("relevantMethods") | ||
@ParameterizedTest(name = "ComposeContext defines {0} correctly") | ||
fun test(method: Method) { | ||
try { | ||
ComposeContext::class.java.getDeclaredMethod(method.name, *method.parameterTypes) | ||
} catch (ignored: NoSuchMethodException) { | ||
fail("ComposeContext does not define method $method") | ||
} | ||
} | ||
} |