Skip to content

Commit

Permalink
add hermit dependency (#140)
Browse files Browse the repository at this point in the history
* add hermit dependency

* add Hermit to the dependency matchers in DocsTasks
  • Loading branch information
RBusarow committed Jun 29, 2020
1 parent fdf3638 commit a212ccc
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ object Libs {

}
}

object Hermit {
private const val version = "0.9.2"
const val core = "com.rickbusarow.hermit:hermit-core:$version"
const val junit4 = "com.rickbusarow.hermit:hermit-junit4:$version"
const val junit5 = "com.rickbusarow.hermit:hermit-junit5:$version"
const val mockk = "com.rickbusarow.hermit:hermit-mockk:$version"
const val coroutines = "com.rickbusarow.hermit:hermit-coroutines:$version"
}
}

object Robolectric {
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/DocsTasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,18 @@ fun File.updateLibraryVersions(): File {
Libs.RickBusarow.Dispatch.Test.jUnit4.toDependencyMatcher(),
Libs.RickBusarow.Dispatch.Test.jUnit5.toDependencyMatcher(),
Libs.RickBusarow.Dispatch.core.toDependencyMatcher(),
Libs.RickBusarow.Hermit.core.toDependencyMatcher(),
Libs.RickBusarow.Hermit.junit4.toDependencyMatcher(),
Libs.RickBusarow.Hermit.junit5.toDependencyMatcher(),
Libs.RickBusarow.Hermit.mockk.toDependencyMatcher(),
Libs.RickBusarow.Hermit.coroutines.toDependencyMatcher(),
Libs.Kotest.assertions.toDependencyMatcher(),
Libs.Kotest.consoleRunner.toDependencyMatcher(),
Libs.Kotest.properties.toDependencyMatcher(),
Libs.Kotest.runner.toDependencyMatcher()
)


forEachLine { originalLine ->

val newLine = dependencyMatchers.firstOrNull { matcher ->
Expand Down
9 changes: 7 additions & 2 deletions dispatch-android-lifecycle-extensions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@ android {

dependencies {

implementation(Libs.AndroidX.Fragment.core)
implementation(Libs.AndroidX.Lifecycle.common)
testImplementation(Libs.AndroidX.Lifecycle.runtime)

implementation(Libs.JakeWharton.timber)

implementation(Libs.Kotlin.stdlib)

implementation(Libs.Kotlinx.Coroutines.android)
implementation(Libs.Kotlinx.Coroutines.core)

api(project(":dispatch-android-lifecycle"))
api(project(":dispatch-core"))
testImplementation(project(":dispatch-test-junit4"))
testImplementation(project(":dispatch-test-junit5"))
testImplementation(project(":dispatch-internal-test"))
testImplementation(project(":dispatch-internal-test-android"))

testImplementation(Libs.JUnit.jUnit5)
testImplementation(Libs.Kotest.assertions)
Expand All @@ -69,4 +70,8 @@ dependencies {

testImplementation(Libs.AndroidX.Test.runner)
testImplementation(Libs.AndroidX.Test.Espresso.core)
testImplementation(Libs.AndroidX.Test.Arch.core)
testImplementation(Libs.Robolectric.core)

testImplementation(Libs.RickBusarow.Hermit.junit5)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package dispatch.android.lifecycle

import dispatch.core.*
import dispatch.internal.test.*
import dispatch.internal.test.android.*
import hermit.test.*
import hermit.test.junit.*
import io.kotest.matchers.*
import io.kotest.matchers.types.*
import kotlinx.coroutines.*
Expand All @@ -26,7 +29,7 @@ import kotlin.coroutines.*

@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
internal class LifecycleScopeFactoryTest {
internal class LifecycleScopeFactoryTest : HermitJUnit5() {

val job = Job()
val dispatcher = newSingleThreadContext("single thread dispatcher")
Expand All @@ -38,6 +41,8 @@ internal class LifecycleScopeFactoryTest {

val mainDispatcher = newSingleThreadContext("main dispatcher")

val lifecycleOwner by resets { FakeLifecycleOwner() }

@BeforeAll
fun beforeAll() {
Dispatchers.setMain(mainDispatcher)
Expand Down
17 changes: 14 additions & 3 deletions dispatch-android-lifecycle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,39 @@ android {

dependencies {

implementation(Libs.AndroidX.Fragment.core)
implementation(Libs.AndroidX.Lifecycle.common)
testImplementation(Libs.AndroidX.Lifecycle.runtime)

implementation(Libs.JakeWharton.timber)

implementation(Libs.Kotlin.stdlib)

implementation(Libs.Kotlinx.Coroutines.android)
implementation(Libs.Kotlinx.Coroutines.core)

api(project(":dispatch-core"))
testImplementation(project(":dispatch-test"))
testImplementation(project(":dispatch-test-junit4"))
testImplementation(project(":dispatch-test-junit5"))
testImplementation(project(":dispatch-internal-test"))
testImplementation(project(":dispatch-internal-test-android"))

testImplementation(Libs.AndroidX.Lifecycle.runtime)

testImplementation(Libs.AndroidX.Test.Arch.core)
testImplementation(Libs.AndroidX.Test.Espresso.core)
testImplementation(Libs.AndroidX.Test.runner)

testImplementation(Libs.JUnit.jUnit5)

testImplementation(Libs.Kotest.assertions)
testImplementation(Libs.Kotest.consoleRunner)
testImplementation(Libs.Kotest.properties)
testImplementation(Libs.Kotest.runner)

testImplementation(Libs.Kotlinx.Coroutines.test)

testImplementation(Libs.RickBusarow.Hermit.coroutines)
testImplementation(Libs.RickBusarow.Hermit.junit5)

testImplementation(Libs.AndroidX.Test.runner)
testImplementation(Libs.AndroidX.Test.Espresso.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
package dispatch.android.lifecycle

import androidx.lifecycle.*
import dispatch.internal.test.android.*
import dispatch.test.*
import hermit.test.*
import hermit.test.junit.*
import io.kotest.matchers.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
Expand All @@ -26,26 +29,16 @@ import org.junit.jupiter.api.*
@FlowPreview
@CoroutineTest
@ExperimentalCoroutinesApi
class LifecycleCoroutineScopeTest(
val testScope: TestProvidedCoroutineScope
) {
class LifecycleCoroutineScopeTest : HermitJUnit5() {

lateinit var lifecycleOwner: LifecycleOwner
lateinit var lifecycle: LifecycleRegistry
val testScope by resets { TestProvidedCoroutineScope(context = Job()) }

lateinit var scope: LifecycleCoroutineScope

@BeforeEach
fun beforeEach() {

lifecycleOwner = LifecycleOwner { lifecycle }
lifecycle = LifecycleRegistry(lifecycleOwner)

scope = LifecycleCoroutineScope(lifecycle, testScope)
}
val lifecycleOwner by resets { FakeLifecycleOwner() }
val lifecycle by resets { lifecycleOwner.lifecycle }
val scope by resets { LifecycleCoroutineScope(lifecycle, testScope) }

@Nested
inner class `launch every create` {
inner class `launch on create` {

@Test
fun `block should immediately execute if already created`() = runBlocking {
Expand Down Expand Up @@ -98,7 +91,7 @@ class LifecycleCoroutineScopeTest(
}

@Nested
inner class `launch every start` {
inner class `launch on start` {

@Test
fun `block should immediately execute if already started`() = runBlocking {
Expand Down Expand Up @@ -163,7 +156,7 @@ class LifecycleCoroutineScopeTest(
}

@Nested
inner class `launch every resume` {
inner class `launch on resume` {

@Test
fun `block should immediately execute if already resumed`() = runBlocking {
Expand Down

0 comments on commit a212ccc

Please sign in to comment.