Issue#13 Add separate task for robolectric tests
This commit is contained in:
parent
f248ab1081
commit
c4c2ea7c26
9 changed files with 23 additions and 22 deletions
|
|
@ -9,7 +9,7 @@ import org.junit.jupiter.api.Disabled
|
|||
|
||||
@Disabled("CodeKata")
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class CodeKataFavouriteContentLocalStorage {
|
||||
class CodeKataFavouriteContentLocalStorageInstrumentedTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
|
|
@ -26,7 +26,7 @@ import org.koin.test.inject
|
|||
@Suppress("TestFunctionName")
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
internal class FavouriteContentLocalStorageImplTest : KoinTest {
|
||||
internal class FavouriteContentLocalStorageImplInstrumentedTest : KoinTest {
|
||||
|
||||
private val sut by inject<FavouriteContentLocalStorage>()
|
||||
private lateinit var testDispatcher: TestDispatcher
|
||||
|
|
@ -25,7 +25,7 @@ import java.io.IOException
|
|||
* https://developer.android.com/training/data-storage/room/migrating-db-versions
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class MigrationToLatest {
|
||||
class MigrationToLatestInstrumentedTest {
|
||||
|
||||
@get:Rule
|
||||
val helper: SharedMigrationTestRule = createSharedMigrationTestRule<LocalDatabase>(
|
||||
|
|
@ -23,7 +23,7 @@ import org.koin.test.KoinTest
|
|||
|
||||
@Suppress("TestFunctionName")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class MainActivityTest : KoinTest {
|
||||
class MainActivityInstrumentedTest : KoinTest {
|
||||
|
||||
private lateinit var activityScenario: ActivityScenario<MainActivity>
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ import org.koin.test.KoinTest
|
|||
|
||||
@Suppress("TestFunctionName")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class AuthActivityTest : KoinTest {
|
||||
class AuthActivityInstrumentedTest : KoinTest {
|
||||
|
||||
private lateinit var activityScenario: ActivityScenario<AuthActivity>
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ import org.koin.test.KoinTest
|
|||
|
||||
@Suppress("TestFunctionName")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class SplashActivityTest : KoinTest {
|
||||
class SplashActivityInstrumentedTest : KoinTest {
|
||||
|
||||
private lateinit var activityScenario: ActivityScenario<SplashActivity>
|
||||
|
||||
15
build.gradle
15
build.gradle
|
|
@ -29,21 +29,6 @@ task clean(type: Delete) {
|
|||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
task unitTests(dependsOn: ["app:testDebugUnitTest", "core:test", "network:test"]){
|
||||
group = 'Tests'
|
||||
description = 'Run all unit tests'
|
||||
}
|
||||
|
||||
task robolectricTests(dependsOn: ["app:testDebugUnitTest"]){
|
||||
group = 'Tests'
|
||||
description = 'Run all robolectric tests'
|
||||
}
|
||||
|
||||
task androidTests(dependsOn: ["app:connectedDebugAndroidTest"]){
|
||||
group = 'Tests'
|
||||
description = 'Run all Android tests'
|
||||
}
|
||||
|
||||
apply from: 'gradlescripts/versions.gradle'
|
||||
apply from: 'gradlescripts/detekt.config.gradle'
|
||||
apply from: 'gradlescripts/ktlint.gradle'
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ What it does is:
|
|||
|
||||
So let's start with the setup.
|
||||
|
||||
Our test class is `org.fnives.test.showcase.storage.favourite.CodeKataFavouriteContentLocalStorage`
|
||||
Our test class is `org.fnives.test.showcase.storage.favourite.CodeKataFavouriteContentLocalStorageInstrumentedTest`
|
||||
|
||||
Question: Why don't we test the DAO and Storage separately using mocking?
|
||||
Answer: The same logic applies how we didn't test the RetrofitServices just the RemoteSources. The Service just like the DAO is an implementation detail, our code only accesses them through the RemoteSource / LocalStorage abstraction. With this in mind now we only want to test that we interact with the database properly, we don't really care how many DAOs are used.
|
||||
|
|
|
|||
|
|
@ -62,4 +62,20 @@ subprojects { module ->
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task jvmTests(dependsOn: ["app:testDebugUnitTest", "core:test", "network:test"]) {
|
||||
group = 'Tests'
|
||||
description = 'Run all JVM tests'
|
||||
}
|
||||
|
||||
task robolectricTests(type: Exec) {
|
||||
group = 'Tests'
|
||||
description = 'Run all Robolectric tests based on the Instrumented naming convention'
|
||||
commandLine 'sh', './gradlew', 'testDebugUnitTest', '--tests', 'org.fnives.test.*InstrumentedTest'
|
||||
}
|
||||
|
||||
task androidTests(dependsOn: ["app:connectedDebugAndroidTest"]) {
|
||||
group = 'Tests'
|
||||
description = 'Run Android tests'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue