Skip to content

Commit

Permalink
Merge branch 'adding-tests' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/res/layout/activity_home.xml
#	app/src/main/res/layout/activity_user_profile.xml
#	app/src/main/res/layout/card_history.xml
  • Loading branch information
NikM3 committed Apr 22, 2023
2 parents 6256218 + 490e995 commit 2ab7d09
Show file tree
Hide file tree
Showing 20 changed files with 617 additions and 60 deletions.
29 changes: 17 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,23 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-database-ktx:20.1.0'
implementation 'com.google.firebase:firebase-database:20.1.0'
implementation 'com.google.firebase:firebase-database-ktx:20.2.0'
implementation 'com.google.firebase:firebase-database:20.2.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'

// Testing dependencies
implementation 'androidx.arch.core:core-testing:2.2.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:runner:1.5.2'
Expand All @@ -66,13 +67,17 @@ dependencies {
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'

// https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy
implementation 'net.bytebuddy:byte-buddy-android:1.14.4'

// Optional -- Mockito framework
testImplementation 'org.mockito:mockito-core:5.0.0'
testImplementation 'org.mockito:mockito-core:5.3.1'
testImplementation 'org.mockito:mockito-android:5.3.1'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0'
testImplementation 'io.mockk:mockk:1.13.4'
testImplementation 'io.mockk:mockk:1.13.5'

// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation platform('com.google.firebase:firebase-bom:31.5.0')

// Add the dependency for the Firebase library
// When using the BoM, you don't specify versions in Firebase library dependencies
Expand All @@ -95,11 +100,11 @@ dependencies {
implementation 'com.firebaseui:firebase-ui-storage:8.0.2'

// Also add the dependency for the Google Play services library and specify its version
implementation 'com.google.android.gms:play-services-auth:20.4.1'
implementation 'com.google.android.gms:play-services-auth:20.5.0'

// Add the dependency for Glide
implementation 'com.github.bumptech.glide:glide:4.15.0'
kapt 'com.github.bumptech.glide:compiler:4.15.0'
implementation 'com.github.bumptech.glide:glide:4.15.1'
kapt 'com.github.bumptech.glide:compiler:4.15.1'

// Konfetti by https://github.com/DanielMartinus/Konfetti
implementation 'nl.dionsegijn:konfetti-xml:2.0.2'
Expand Down
69 changes: 69 additions & 0 deletions app/src/androidTest/java/com/symphony/mrfit/ui/ExerciseTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Created by Team Symphony on 4/21/23, 10:18 PM
* Copyright (c) 2023 . All rights reserved.
* Last modified 4/21/23, 10:18 PM
*/

package com.symphony.mrfit.ui

import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.symphony.mrfit.R
import org.hamcrest.Matchers
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
@LargeTest
class ExerciseTest {

@Before
fun setUp() {
}

@get:Rule
var activityScenarioRule = activityScenarioRule<ExerciseActivity>()

/**
* Test if the activity is displayed and visible to user
*/
@Test
fun checkActivityVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.layout_exerciseSelectionActivity))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

/**
* Test if all the appropriate components are visible
*/
@Test
fun checkViewVisibility() {
Thread.sleep(500)
Espresso.onView(ViewMatchers.withId(R.id.exerciseScreenView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.exerciseListView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.exerciseSearchTextView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.exerciseSearchEditText))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.exerciseSearchButton))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.button2))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner))
.check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed())))
}
}
83 changes: 83 additions & 0 deletions app/src/androidTest/java/com/symphony/mrfit/ui/HomeActivityTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Created by Team Symphony on 4/21/23, 10:18 PM
* Copyright (c) 2023 . All rights reserved.
* Last modified 4/21/23, 10:18 PM
*/

package com.symphony.mrfit.ui

import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.symphony.mrfit.R
import org.hamcrest.Matchers.not
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
@LargeTest
class HomeActivityTest {

@Before
fun setUp() {
}

@get:Rule
var activityScenarioRule = activityScenarioRule<HomeActivity>()

/**
* Test if the activity is displayed and visible to user
*/
@Test
fun checkActivityVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.layout_homeActivity))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

/**
* Test if all the appropriate components are visible
*/
@Test
fun checkViewVisibility() {
Thread.sleep(1000)
Espresso.onView(ViewMatchers.withId(R.id.homeScreenView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.userLayout))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.homeProfilePicture))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.homeWelcomeTextView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.homeNameTextView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
Espresso.onView(ViewMatchers.withId(R.id.homeScreenView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.settingsCog))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.scheduleButton))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.pastWorkout))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.workoutButton))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.historyList))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner))
.check(ViewAssertions.matches(not(ViewMatchers.isDisplayed())))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Created by Team Symphony on 4/21/23, 5:08 PM
* Copyright (c) 2023 . All rights reserved.
* Last modified 4/21/23, 4:12 PM
*/

package com.symphony.mrfit.ui

import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.symphony.mrfit.R
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
@LargeTest
class RegisterActivityTest {

@get:Rule
var activityScenarioRule = activityScenarioRule<RegisterActivity>()

/**
* Test if the activity is displayed and visible to user
*/
@Test
fun checkActivityVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.layout_registerActivity))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

/**
* Test if all the components are visible
*/
@Test
fun checkViewVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.registerEmail))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.registerPassword))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.confirmPassword))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.registerButton))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.toLoginTextView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Created by Team Symphony on 4/21/23, 10:18 PM
* Copyright (c) 2023 . All rights reserved.
* Last modified 4/21/23, 9:24 PM
*/

package com.symphony.mrfit.ui

import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.symphony.mrfit.R
import org.hamcrest.Matchers
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
@LargeTest
class TemplateSelectionActivityTest {

@Before
fun setUp() {
}

@get:Rule
var activityScenarioRule = activityScenarioRule<RoutineSelectionActivity>()

/**
* Test if the activity is displayed and visible to user
*/
@Test
fun checkActivityVisibility() {
Espresso.onView(ViewMatchers.withId(R.id.layout_selectionActivity))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

/**
* Test if all the appropriate components are visible
*/
@Test
fun checkViewVisibility() {
Thread.sleep(500)
Espresso.onView(ViewMatchers.withId(R.id.selectionScreenView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.routineListView))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.newWorkoutButton))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withId(R.id.loadingSpinner))
.check(ViewAssertions.matches(Matchers.not(ViewMatchers.isDisplayed())))
}
}
Loading

0 comments on commit 2ab7d09

Please sign in to comment.