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 {
4141 testImplementation(project(" :kotest-extensions-android" ))
4242 testImplementation(" io.kotest:kotest-runner-junit5:5.9.1" )
4343 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" )
4446 androidTestImplementation(" androidx.test:runner:1.5.2" )
4547 androidTestImplementation(" androidx.test:core:1.5.0" )
4648 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
66import org.robolectric.RobolectricTestRunner
77import org.robolectric.annotation.Config
88import org.robolectric.internal.bytecode.InstrumentationConfiguration
9+ import org.robolectric.pluginapi.config.ConfigurationStrategy
910import org.robolectric.pluginapi.config.Configurer
1011import org.robolectric.plugins.HierarchicalConfigurationStrategy
1112import org.robolectric.util.inject.Injector
@@ -65,7 +66,10 @@ internal class ContainedRobolectricRunner(
6566
6667 companion object {
6768 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()
6973 return Injector .Builder (defaultInjector, ContainedRobolectricRunner ::class .java.classLoader)
7074 .build()
7175 }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments