File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed
kotest-extensions-android
kotest-extensions-android-tests
src/test/kotlin/br/com/colman/kotest/android/extensions
kotlin/br/com/colman/kotest/android/extensions/robolectric
resources/META-INF/services Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ dependencies {
41
41
testImplementation(project(" :kotest-extensions-android" ))
42
42
testImplementation(" io.kotest:kotest-runner-junit5:5.9.1" )
43
43
testImplementation(" org.robolectric:robolectric:4.12.2" )
44
+ testImplementation(" androidx.test.espresso:espresso-core:3.6.1" )
45
+ testImplementation(" org.junit.vintage:junit-vintage-engine:5.11.3" )
44
46
androidTestImplementation(" androidx.test:runner:1.5.2" )
45
47
androidTestImplementation(" androidx.test:core:1.5.0" )
46
48
androidTestImplementation(" androidx.test:rules:1.5.0" )
Original file line number Diff line number Diff line change
1
+ package br.com.colman.kotest.android.extensions
2
+
3
+ import androidx.test.core.app.ActivityScenario.launch
4
+ import androidx.test.espresso.Espresso.onView
5
+ import androidx.test.espresso.assertion.ViewAssertions.matches
6
+ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
7
+ import androidx.test.espresso.matcher.ViewMatchers.withId
8
+ import androidx.test.espresso.matcher.ViewMatchers.withText
9
+ import br.com.colman.kotest.R
10
+ import br.com.colman.kotest.TestActivity
11
+ import org.junit.Test
12
+ import org.junit.runner.RunWith
13
+ import org.robolectric.RobolectricTestRunner
14
+
15
+ @RunWith(RobolectricTestRunner ::class )
16
+ class NoKotestRobolectricTest {
17
+ @Test
18
+ fun `TextView in TestActivity has Hello World!` () {
19
+ launch(TestActivity ::class .java)
20
+
21
+ onView(withId(R .id.textView))
22
+ .check(matches(isDisplayed()))
23
+ .check(matches(withText(" Hello World!" )))
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import org.junit.runners.model.FrameworkMethod
6
6
import org.robolectric.RobolectricTestRunner
7
7
import org.robolectric.annotation.Config
8
8
import org.robolectric.internal.bytecode.InstrumentationConfiguration
9
+ import org.robolectric.pluginapi.config.ConfigurationStrategy
9
10
import org.robolectric.pluginapi.config.Configurer
10
11
import org.robolectric.plugins.HierarchicalConfigurationStrategy
11
12
import org.robolectric.util.inject.Injector
@@ -65,7 +66,10 @@ internal class ContainedRobolectricRunner(
65
66
66
67
companion object {
67
68
private fun kotestInjector (config : Config ): Injector {
68
- val defaultInjector = defaultInjector().bind(Config ::class .java, config).build()
69
+ val defaultInjector = defaultInjector()
70
+ .bind(Config ::class .java, config)
71
+ .bind(ConfigurationStrategy ::class .java, KotestHierarchicalConfigurationStrategy ::class .java)
72
+ .build()
69
73
return Injector .Builder (defaultInjector, ContainedRobolectricRunner ::class .java.classLoader)
70
74
.build()
71
75
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments