Issue#67 Fix Code Analysis errors
This commit is contained in:
parent
99141c0f17
commit
8d60a37b16
16 changed files with 31 additions and 24 deletions
|
|
@ -4,13 +4,13 @@ import androidx.compose.ui.test.junit4.StateRestorationTester
|
||||||
import androidx.compose.ui.test.junit4.createComposeRule
|
import androidx.compose.ui.test.junit4.createComposeRule
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.fnives.test.showcase.R
|
import org.fnives.test.showcase.R
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.anyResourceIdling
|
||||||
import org.fnives.test.showcase.compose.screen.AppNavigation
|
import org.fnives.test.showcase.compose.screen.AppNavigation
|
||||||
import org.fnives.test.showcase.core.integration.fake.FakeUserDataLocalStorage
|
import org.fnives.test.showcase.core.integration.fake.FakeUserDataLocalStorage
|
||||||
import org.fnives.test.showcase.core.login.IsUserLoggedInUseCase
|
import org.fnives.test.showcase.core.login.IsUserLoggedInUseCase
|
||||||
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
||||||
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
||||||
import org.fnives.test.showcase.testutils.idling.DatabaseDispatcherTestRule
|
import org.fnives.test.showcase.testutils.idling.DatabaseDispatcherTestRule
|
||||||
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.anyResourceIdling
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import androidx.lifecycle.Lifecycle
|
||||||
import androidx.test.core.app.ActivityScenario
|
import androidx.test.core.app.ActivityScenario
|
||||||
import androidx.test.espresso.intent.Intents
|
import androidx.test.espresso.intent.Intents
|
||||||
import androidx.test.runner.intent.IntentStubberRegistry
|
import androidx.test.runner.intent.IntentStubberRegistry
|
||||||
|
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
||||||
import org.fnives.test.showcase.network.mockserver.MockServerScenarioSetup
|
import org.fnives.test.showcase.network.mockserver.MockServerScenarioSetup
|
||||||
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
||||||
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
||||||
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
|
||||||
import org.fnives.test.showcase.ui.auth.AuthActivity
|
import org.fnives.test.showcase.ui.auth.AuthActivity
|
||||||
import org.fnives.test.showcase.ui.home.HomeRobot
|
import org.fnives.test.showcase.ui.home.HomeRobot
|
||||||
import org.fnives.test.showcase.ui.home.MainActivity
|
import org.fnives.test.showcase.ui.home.MainActivity
|
||||||
|
|
@ -19,7 +19,7 @@ object SetupAuthenticationState : KoinTest {
|
||||||
fun setupLogin(
|
fun setupLogin(
|
||||||
mainDispatcherTestRule: MainDispatcherTestRule,
|
mainDispatcherTestRule: MainDispatcherTestRule,
|
||||||
mockServerScenarioSetup: MockServerScenarioSetup,
|
mockServerScenarioSetup: MockServerScenarioSetup,
|
||||||
resetIntents: Boolean = true
|
resetIntents: Boolean = true,
|
||||||
) {
|
) {
|
||||||
resetIntentsIfNeeded(resetIntents) {
|
resetIntentsIfNeeded(resetIntents) {
|
||||||
mockServerScenarioSetup.setScenario(AuthScenario.Success(username = "a", password = "b"))
|
mockServerScenarioSetup.setScenario(AuthScenario.Success(username = "a", password = "b"))
|
||||||
|
|
@ -40,7 +40,7 @@ object SetupAuthenticationState : KoinTest {
|
||||||
|
|
||||||
fun setupLogout(
|
fun setupLogout(
|
||||||
mainDispatcherTestRule: MainDispatcherTestRule,
|
mainDispatcherTestRule: MainDispatcherTestRule,
|
||||||
resetIntents: Boolean = true
|
resetIntents: Boolean = true,
|
||||||
) {
|
) {
|
||||||
resetIntentsIfNeeded(resetIntents) {
|
resetIntentsIfNeeded(resetIntents) {
|
||||||
val activityScenario = ActivityScenario.launch(MainActivity::class.java)
|
val activityScenario = ActivityScenario.launch(MainActivity::class.java)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import androidx.test.core.app.ActivityScenario
|
||||||
import androidx.test.espresso.intent.Intents
|
import androidx.test.espresso.intent.Intents
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.loopMainThreadFor
|
||||||
import org.fnives.test.showcase.model.content.FavouriteContent
|
import org.fnives.test.showcase.model.content.FavouriteContent
|
||||||
import org.fnives.test.showcase.network.mockserver.ContentData
|
import org.fnives.test.showcase.network.mockserver.ContentData
|
||||||
import org.fnives.test.showcase.network.mockserver.scenario.content.ContentScenario
|
import org.fnives.test.showcase.network.mockserver.scenario.content.ContentScenario
|
||||||
|
|
@ -11,7 +12,6 @@ import org.fnives.test.showcase.network.mockserver.scenario.refresh.RefreshToken
|
||||||
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
||||||
import org.fnives.test.showcase.testutils.idling.AsyncDiffUtilInstantTestRule
|
import org.fnives.test.showcase.testutils.idling.AsyncDiffUtilInstantTestRule
|
||||||
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
||||||
import org.fnives.test.showcase.android.testutil.synchronization.loopMainThreadFor
|
|
||||||
import org.fnives.test.showcase.testutils.statesetup.SetupAuthenticationState.setupLogin
|
import org.fnives.test.showcase.testutils.statesetup.SetupAuthenticationState.setupLogin
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import androidx.test.core.app.ActivityScenario
|
||||||
import androidx.test.espresso.intent.Intents
|
import androidx.test.espresso.intent.Intents
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.fnives.test.showcase.R
|
import org.fnives.test.showcase.R
|
||||||
|
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
||||||
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
||||||
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
||||||
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
||||||
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
|
||||||
import org.fnives.test.showcase.ui.auth.AuthActivity
|
import org.fnives.test.showcase.ui.auth.AuthActivity
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ import androidx.test.espresso.intent.Intents
|
||||||
import androidx.test.espresso.intent.matcher.IntentMatchers
|
import androidx.test.espresso.intent.matcher.IntentMatchers
|
||||||
import androidx.test.espresso.matcher.ViewMatchers
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
import org.fnives.test.showcase.R
|
import org.fnives.test.showcase.R
|
||||||
|
import org.fnives.test.showcase.android.testutil.intent.notIntended
|
||||||
import org.fnives.test.showcase.android.testutil.snackbar.SnackbarVerificationHelper.assertSnackBarIsNotShown
|
import org.fnives.test.showcase.android.testutil.snackbar.SnackbarVerificationHelper.assertSnackBarIsNotShown
|
||||||
import org.fnives.test.showcase.android.testutil.snackbar.SnackbarVerificationHelper.assertSnackBarIsShownWithText
|
import org.fnives.test.showcase.android.testutil.snackbar.SnackbarVerificationHelper.assertSnackBarIsShownWithText
|
||||||
import org.fnives.test.showcase.android.testutil.intent.notIntended
|
|
||||||
import org.fnives.test.showcase.ui.home.MainActivity
|
import org.fnives.test.showcase.ui.home.MainActivity
|
||||||
import org.hamcrest.core.IsNot
|
import org.hamcrest.core.IsNot
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ import androidx.lifecycle.Lifecycle
|
||||||
import androidx.test.core.app.ActivityScenario
|
import androidx.test.core.app.ActivityScenario
|
||||||
import androidx.test.espresso.intent.Intents
|
import androidx.test.espresso.intent.Intents
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
||||||
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
import org.fnives.test.showcase.testutils.MockServerScenarioSetupResetingTestRule
|
||||||
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule
|
||||||
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
|
||||||
import org.fnives.test.showcase.testutils.statesetup.SetupAuthenticationState.setupLogin
|
import org.fnives.test.showcase.testutils.statesetup.SetupAuthenticationState.setupLogin
|
||||||
import org.fnives.test.showcase.testutils.statesetup.SetupAuthenticationState.setupLogout
|
import org.fnives.test.showcase.testutils.statesetup.SetupAuthenticationState.setupLogout
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,11 @@ internal class AuthViewModelTest {
|
||||||
@DisplayName("GIVEN initialized viewModel WHEN observed THEN loading false other fields are empty")
|
@DisplayName("GIVEN initialized viewModel WHEN observed THEN loading false other fields are empty")
|
||||||
@Test
|
@Test
|
||||||
fun initialSetup() {
|
fun initialSetup() {
|
||||||
|
var a = ""
|
||||||
|
repeat(1200 / 2) {
|
||||||
|
a += "a "
|
||||||
|
}
|
||||||
|
System.err.println(a+"b")
|
||||||
val usernameTestObserver = sut.username.test()
|
val usernameTestObserver = sut.username.test()
|
||||||
val passwordTestObserver = sut.password.test()
|
val passwordTestObserver = sut.password.test()
|
||||||
val loadingTestObserver = sut.loading.test()
|
val loadingTestObserver = sut.loading.test()
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ project.ext {
|
||||||
def testing_json_assert_version = propertyOrNull('json_assert_version') ?: "1.5.0"
|
def testing_json_assert_version = propertyOrNull('json_assert_version') ?: "1.5.0"
|
||||||
def testing_okhttp3 = propertyOrNull('okhttp_version') ?: "4.9.3"
|
def testing_okhttp3 = propertyOrNull('okhttp_version') ?: "4.9.3"
|
||||||
def testing_turbine_version = propertyOrNull('turbine_version') ?: "0.7.0"
|
def testing_turbine_version = propertyOrNull('turbine_version') ?: "0.7.0"
|
||||||
def testing_androidx_room_version = propertyOrNull('room_version') ?: "2.4.1"
|
def testing_androidx_room_version = propertyOrNull('room_version') ?: "2.4.2"
|
||||||
def testing_livedata_version = propertyOrNull('testing_livedata_version') ?: "1.2.0"
|
def testing_livedata_version = propertyOrNull('testing_livedata_version') ?: "1.2.0"
|
||||||
def testing_compose_version = propertyOrNull('compose_version') ?: "1.1.0"
|
def testing_compose_version = propertyOrNull('compose_version') ?: "1.1.0"
|
||||||
def testing_hamcrest_version = propertyOrNull('hamcrest_version')?: "2.2"
|
def testing_hamcrest_version = propertyOrNull('hamcrest_version')?: "2.2"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ project.ext {
|
||||||
androidx_constraintlayout_version = "2.1.3"
|
androidx_constraintlayout_version = "2.1.3"
|
||||||
androidx_livedata_version = "2.4.0"
|
androidx_livedata_version = "2.4.0"
|
||||||
androidx_swiperefreshlayout_version = "1.1.0"
|
androidx_swiperefreshlayout_version = "1.1.0"
|
||||||
room_version = "2.4.1"
|
room_version = "2.4.2"
|
||||||
activity_ktx_version = "1.4.0"
|
activity_ktx_version = "1.4.0"
|
||||||
androidx_navigation = "2.4.0"
|
androidx_navigation = "2.4.0"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import androidx.test.espresso.intent.Intents.intended
|
||||||
import org.hamcrest.Matcher
|
import org.hamcrest.Matcher
|
||||||
import org.hamcrest.StringDescription
|
import org.hamcrest.StringDescription
|
||||||
|
|
||||||
|
@Suppress("SwallowedException")
|
||||||
fun notIntended(matcher: Matcher<Intent>) {
|
fun notIntended(matcher: Matcher<Intent>) {
|
||||||
try {
|
try {
|
||||||
intended(matcher)
|
intended(matcher)
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ import androidx.test.espresso.ViewAction
|
||||||
import androidx.test.espresso.action.ViewActions
|
import androidx.test.espresso.action.ViewActions
|
||||||
import androidx.test.espresso.assertion.ViewAssertions
|
import androidx.test.espresso.assertion.ViewAssertions
|
||||||
import androidx.test.espresso.matcher.ViewMatchers
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
import com.google.android.material.R as MaterialR
|
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import org.hamcrest.Matcher
|
import org.hamcrest.Matcher
|
||||||
import org.hamcrest.Matchers
|
import org.hamcrest.Matchers
|
||||||
|
import com.google.android.material.R as MaterialR
|
||||||
|
|
||||||
object SnackbarVerificationHelper {
|
object SnackbarVerificationHelper {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import androidx.room.migration.AutoMigrationSpec
|
||||||
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
||||||
import org.fnives.test.showcase.android.testutil.robolectric.RobolectricMigrationTestRule
|
import org.fnives.test.showcase.android.testutil.robolectric.RobolectricMigrationTestRule
|
||||||
|
|
||||||
inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
|
inline fun <reified Database : RoomDatabase> SharedMigrationTestRule(
|
||||||
instrumentation: Instrumentation
|
instrumentation: Instrumentation,
|
||||||
): SharedMigrationTestRule =
|
): SharedMigrationTestRule =
|
||||||
createAndroidClassOrRobolectric(
|
createAndroidClassOrRobolectric(
|
||||||
androidClassFactory = { androidClass ->
|
androidClassFactory = { androidClass ->
|
||||||
|
|
@ -22,9 +22,9 @@ inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
|
inline fun <reified Database : RoomDatabase> SharedMigrationTestRule(
|
||||||
instrumentation: Instrumentation,
|
instrumentation: Instrumentation,
|
||||||
specs: List<AutoMigrationSpec>
|
specs: List<AutoMigrationSpec>,
|
||||||
): SharedMigrationTestRule =
|
): SharedMigrationTestRule =
|
||||||
createAndroidClassOrRobolectric(
|
createAndroidClassOrRobolectric(
|
||||||
androidClassFactory = { androidClass ->
|
androidClassFactory = { androidClass ->
|
||||||
|
|
@ -40,10 +40,10 @@ inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
|
inline fun <reified Database : RoomDatabase> SharedMigrationTestRule(
|
||||||
instrumentation: Instrumentation,
|
instrumentation: Instrumentation,
|
||||||
specs: List<AutoMigrationSpec>,
|
specs: List<AutoMigrationSpec>,
|
||||||
openFactory: SupportSQLiteOpenHelper.Factory
|
openFactory: SupportSQLiteOpenHelper.Factory,
|
||||||
): SharedMigrationTestRule =
|
): SharedMigrationTestRule =
|
||||||
createAndroidClassOrRobolectric(
|
createAndroidClassOrRobolectric(
|
||||||
androidClassFactory = { androidClass ->
|
androidClassFactory = { androidClass ->
|
||||||
|
|
@ -62,7 +62,7 @@ inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
|
||||||
|
|
||||||
fun createAndroidClassOrRobolectric(
|
fun createAndroidClassOrRobolectric(
|
||||||
androidClassFactory: (Class<*>) -> Any,
|
androidClassFactory: (Class<*>) -> Any,
|
||||||
robolectricFactory: () -> SharedMigrationTestRule
|
robolectricFactory: () -> SharedMigrationTestRule,
|
||||||
): SharedMigrationTestRule {
|
): SharedMigrationTestRule {
|
||||||
val androidClass = getAndroidClass()
|
val androidClass = getAndroidClass()
|
||||||
return if (androidClass == null) {
|
return if (androidClass == null) {
|
||||||
|
|
@ -72,6 +72,7 @@ fun createAndroidClassOrRobolectric(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("SwallowedException")
|
||||||
private fun getAndroidClass() = try {
|
private fun getAndroidClass() = try {
|
||||||
Class.forName("org.fnives.test.showcase.android.testutil.AndroidMigrationTestRule")
|
Class.forName("org.fnives.test.showcase.android.testutil.AndroidMigrationTestRule")
|
||||||
} catch (classNotFoundException: ClassNotFoundException) {
|
} catch (classNotFoundException: ClassNotFoundException) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue