From 522ecae87a1ebcd21b5583affa43004674c23bce Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Mon, 15 May 2023 15:11:50 +0200 Subject: [PATCH 01/20] fist test --- .idea/androidTestResultsUserPreferences.xml | 50 +++++++++++++ .idea/misc.xml | 3 +- app/build.gradle | 10 ++- .../be/ugent/sel/studeez/SessionScreenTest.kt | 70 +++++++++++++++++++ .../InvisibleSessionManagerTest.kt | 1 - build.gradle | 7 +- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 8 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 .idea/androidTestResultsUserPreferences.xml create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml new file mode 100644 index 0000000..a751b96 --- /dev/null +++ b/.idea/androidTestResultsUserPreferences.xml @@ -0,0 +1,50 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0ad17cb..773fe0f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,6 @@ - - + diff --git a/app/build.gradle b/app/build.gradle index a19cbd7..bc5cfaf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,6 +65,8 @@ dependencies { implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation 'androidx.compose.material:material:1.2.0' + implementation 'androidx.test.ext:junit-ktx:1.1.5' + implementation 'androidx.navigation:navigation-testing:2.5.3' debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" @@ -96,13 +98,17 @@ dependencies { // JUnit testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" // Coroutine testing testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' // Mocking testImplementation 'org.mockito.kotlin:mockito-kotlin:3.2.0' + androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.28.1' + androidTestImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0" // Networking implementation 'com.squareup.retrofit2:retrofit:2.9.0' @@ -111,8 +117,6 @@ dependencies { testImplementation 'androidx.arch.core:core-testing:2.1.0' // GUI testing - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" //Firebase diff --git a/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt b/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt new file mode 100644 index 0000000..65fb5eb --- /dev/null +++ b/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt @@ -0,0 +1,70 @@ +package be.ugent.sel.studeez + +import androidx.compose.ui.Modifier +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import be.ugent.sel.studeez.data.local.models.SessionReport +import be.ugent.sel.studeez.screens.session_recap.SessionRecapActions +import be.ugent.sel.studeez.screens.session_recap.SessionRecapScreen +import com.google.firebase.Timestamp +import org.junit.Assert +import org.junit.Rule +import org.junit.Test + + +class SessionScreenTest { + @get:Rule + val composeTestRule = createComposeRule() + + @Test + fun SessionRecapTest() { + var saveCalled = false + var discardCalled = false + + composeTestRule.setContent { + SessionRecapScreen( + Modifier, + SessionRecapActions( + { + SessionReport( + "", + 0, + Timestamp(0, 0), + "") + }, + { saveCalled = true }, + { discardCalled = true } + ) + ) + } + composeTestRule + .onNodeWithText( + "You studied", + substring = true, + ignoreCase = true + ) + .assertExists() + + composeTestRule + .onNodeWithText( + "save", + substring = true, + ignoreCase = true + ) + .assertExists() + .performClick() + + composeTestRule + .onNodeWithText( + "discard", + substring = true, + ignoreCase = true + ) + .assertExists() + .performClick() + + Assert.assertTrue(saveCalled) + Assert.assertTrue(discardCalled) + } +} diff --git a/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt b/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt index 54f673d..0c973a5 100644 --- a/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt +++ b/app/src/test/java/be/ugent/sel/studeez/timer_functional/InvisibleSessionManagerTest.kt @@ -6,7 +6,6 @@ import be.ugent.sel.studeez.data.SelectedTimer import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalCustomTimer import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalEndlessTimer import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer -import be.ugent.sel.studeez.domain.LogService import be.ugent.sel.studeez.domain.implementation.LogServiceImpl import be.ugent.sel.studeez.screens.session.InvisibleSessionManager import be.ugent.sel.studeez.screens.session.SessionViewModel diff --git a/build.gradle b/build.gradle index 7f25617..7f70dd1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ buildscript { ext { - compose_ui_version = '1.2.0' compose_version = '1.1.1' coreTestingVersion = '2.1.0' espressoVersion = '3.4.0' @@ -9,13 +8,13 @@ buildscript { dependencies { classpath 'com.google.gms:google-services:4.3.15' - classpath 'com.android.tools.build:gradle:7.2.0' + classpath 'com.android.tools.build:gradle:8.0.0' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4' } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '7.4.2' apply false - id 'com.android.library' version '7.4.2' apply false + id 'com.android.application' version '8.0.0' apply false + id 'com.android.library' version '8.0.0' apply false id 'org.jetbrains.kotlin.android' version '1.7.0' apply false // Hilt diff --git a/gradle.properties b/gradle.properties index edf11ef..8581bd2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,4 +22,6 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true +android.defaults.buildfeatures.buildconfig=true +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 435a2d6..a38b6fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Mar 25 16:03:50 CET 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 74526bc98451a3c30177b4e92a60ba35b82f5f92 Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Mon, 15 May 2023 15:58:59 +0200 Subject: [PATCH 02/20] proto error --- .idea/androidTestResultsUserPreferences.xml | 26 ++++++++++++ app/build.gradle | 12 ++---- .../be/ugent/sel/studeez/HomeScreenTest.kt | 42 +++++++++++++++++++ ...nstrumentedTest.kt => InstrumentedTest.kt} | 2 +- .../be/ugent/sel/studeez/SessionScreenTest.kt | 4 +- build.gradle | 8 ++-- 6 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/HomeScreenTest.kt rename app/src/androidTest/java/be/ugent/sel/studeez/{ExampleInstrumentedTest.kt => InstrumentedTest.kt} (95%) diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml index a751b96..59f6bc1 100644 --- a/.idea/androidTestResultsUserPreferences.xml +++ b/.idea/androidTestResultsUserPreferences.xml @@ -16,6 +16,19 @@ + + + + + + + @@ -44,6 +57,19 @@ + + + + + + + diff --git a/app/build.gradle b/app/build.gradle index bc5cfaf..197b055 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,8 +65,6 @@ dependencies { implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation 'androidx.compose.material:material:1.2.0' - implementation 'androidx.test.ext:junit-ktx:1.1.5' - implementation 'androidx.navigation:navigation-testing:2.5.3' debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" @@ -98,17 +96,13 @@ dependencies { // JUnit testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" + androidTestImplementation 'androidx.test.ext:junit:1.1.5' // Coroutine testing testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' // Mocking testImplementation 'org.mockito.kotlin:mockito-kotlin:3.2.0' - androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.28.1' - androidTestImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0" // Networking implementation 'com.squareup.retrofit2:retrofit:2.9.0' @@ -117,6 +111,8 @@ dependencies { testImplementation 'androidx.arch.core:core-testing:2.1.0' // GUI testing + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" //Firebase @@ -154,4 +150,4 @@ protobuf { } } } -} +} \ No newline at end of file diff --git a/app/src/androidTest/java/be/ugent/sel/studeez/HomeScreenTest.kt b/app/src/androidTest/java/be/ugent/sel/studeez/HomeScreenTest.kt new file mode 100644 index 0000000..fa60dee --- /dev/null +++ b/app/src/androidTest/java/be/ugent/sel/studeez/HomeScreenTest.kt @@ -0,0 +1,42 @@ +package be.ugent.sel.studeez + +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import be.ugent.sel.studeez.common.composable.drawer.DrawerActions +import be.ugent.sel.studeez.common.composable.feed.FeedUiState +import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions +import be.ugent.sel.studeez.data.local.models.FeedEntry +import be.ugent.sel.studeez.screens.home.HomeScreen +import org.junit.Rule +import org.junit.Test + +class HomeScreenTest { + @get:Rule + val composeTestRule = createComposeRule() + + @Test + fun sessionRecapTestt() { + var saveCalled = false + + composeTestRule.setContent { + HomeScreen( + open = {}, + drawerActions = DrawerActions({}, {}, {}, {}, {}), + navigationBarActions = NavigationBarActions({false}, {}, {}, {}, {}, {}, {}, {}), + feedUiState = FeedUiState.Succes(mapOf()), + continueTask = {_, _ -> }, + onEmptyFeedHelp = {} + ) + } + + composeTestRule + .onNodeWithText( + "continue", + substring = true, + ignoreCase = true + ) + .assertExists() + .performClick() + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/be/ugent/sel/studeez/ExampleInstrumentedTest.kt b/app/src/androidTest/java/be/ugent/sel/studeez/InstrumentedTest.kt similarity index 95% rename from app/src/androidTest/java/be/ugent/sel/studeez/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/be/ugent/sel/studeez/InstrumentedTest.kt index 06f9435..d6a1522 100644 --- a/app/src/androidTest/java/be/ugent/sel/studeez/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/be/ugent/sel/studeez/InstrumentedTest.kt @@ -14,7 +14,7 @@ import org.junit.Assert.* * See [testing documentation](http://d.android.com/tools/testing). */ @RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { +class InstrumentedTest { @Test fun useAppContext() { // Context of the app under test. diff --git a/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt b/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt index 65fb5eb..995f0a2 100644 --- a/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt +++ b/app/src/androidTest/java/be/ugent/sel/studeez/SessionScreenTest.kt @@ -18,7 +18,7 @@ class SessionScreenTest { val composeTestRule = createComposeRule() @Test - fun SessionRecapTest() { + fun sessionRecapTest() { var saveCalled = false var discardCalled = false @@ -67,4 +67,6 @@ class SessionScreenTest { Assert.assertTrue(saveCalled) Assert.assertTrue(discardCalled) } + + } diff --git a/build.gradle b/build.gradle index 7f70dd1..4535dd7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ buildscript { ext { + compose_ui_version = '1.2.0' compose_version = '1.1.1' coreTestingVersion = '2.1.0' espressoVersion = '3.4.0' @@ -8,16 +9,15 @@ buildscript { dependencies { classpath 'com.google.gms:google-services:4.3.15' - classpath 'com.android.tools.build:gradle:8.0.0' + classpath 'com.android.tools.build:gradle:7.2.0' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4' } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.0.0' apply false - id 'com.android.library' version '8.0.0' apply false + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false id 'org.jetbrains.kotlin.android' version '1.7.0' apply false // Hilt id 'com.google.dagger.hilt.android' version '2.44' apply false } - From 860fb5fac190bb86e35c86ef0e7c30335542bf7f Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Mon, 15 May 2023 21:53:04 +0200 Subject: [PATCH 03/20] ui tests --- .idea/androidTestResultsUserPreferences.xml | 338 ++++++++++++++++++ app/build.gradle | 2 +- .../java/be/ugent/sel/studeez/FabTest.kt | 74 ++++ .../be/ugent/sel/studeez/HomeScreenTest.kt | 173 ++++++++- .../be/ugent/sel/studeez/LoginScreenTest.kt | 68 ++++ .../sel/studeez/ProfileEditScreenTest.kt | 68 ++++ .../be/ugent/sel/studeez/ProfileScreenTest.kt | 42 +++ .../sel/studeez/SessionRecapScreenTest.kt | 75 ++++ .../be/ugent/sel/studeez/SessionScreenTest.kt | 123 +++++-- .../be/ugent/sel/studeez/SignUpScreenTest.kt | 52 +++ .../be/ugent/sel/studeez/SplashScreenTest.kt | 40 +++ .../be/ugent/sel/studeez/SubjectScreenTest.kt | 155 ++++++++ .../be/ugent/sel/studeez/TaskScreenTest.kt | 160 +++++++++ .../sel/studeez/TimerOverviewScreenTest.kt | 58 +++ .../be/ugent/sel/studeez/TimerScreenTest.kt | 37 ++ .../sel/studeez/TimerSelectionScreenTest.kt | 40 +++ .../screens/timer_form/TimerFormRoute.kt | 13 + .../TimerTypeSelectScreen.kt | 10 + .../InvisibleSessionManagerTest.kt | 7 +- build.gradle | 6 +- 20 files changed, 1492 insertions(+), 49 deletions(-) create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/FabTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/LoginScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/ProfileEditScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/ProfileScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/SessionRecapScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/SignUpScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/SplashScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/SubjectScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/TaskScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/TimerOverviewScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/TimerScreenTest.kt create mode 100644 app/src/androidTest/java/be/ugent/sel/studeez/TimerSelectionScreenTest.kt diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml index 59f6bc1..c9ff4ce 100644 --- a/.idea/androidTestResultsUserPreferences.xml +++ b/.idea/androidTestResultsUserPreferences.xml @@ -3,6 +3,19 @@