Skip to content

Commit

Permalink
Merge pull request #155 from SCCapstone/esambranch
Browse files Browse the repository at this point in the history
Unit Testing #75
  • Loading branch information
Esartawi authored Apr 22, 2023
2 parents f4d6103 + 90f0172 commit f90150a
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.symphony.mrfit.ui

import org.junit.Assert.*

import org.junit.Test

class CalendarActivityTest {
//behavioral
@Test
fun onCreate() {
}
@Test
fun onStart() {
}
@Test
fun onSupportNavigateUp() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.symphony.mrfit.ui
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.junit.After
import org.junit.Assert.*
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.assertEquals




@RunWith(AndroidJUnit4::class)
class CurrentWorkoutActivityTest {
//behavioral
@Test
fun onCreate() {

}
//behavioral
@Test
fun onStart() {

}
@Test
fun gotoHome() {
// Start the activity
val context = ApplicationProvider.getApplicationContext<Context>()
val intent = Intent(context, HomeActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

val expectedFlags = (Intent.FLAG_ACTIVITY_CLEAR_TOP or
Intent.FLAG_ACTIVITY_CLEAR_TASK or
Intent.FLAG_ACTIVITY_NEW_TASK)

assertEquals(expectedFlags, intent.flags)
assertEquals(context.packageName, intent.component?.packageName)
assertEquals(HomeActivity::class.java.name, intent.component?.className)
}
//behavioral
@Test
fun onSupportNavigateUp() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.symphony.mrfit.ui

import androidx.test.core.app.ApplicationProvider
import com.symphony.mrfit.data.exercise.ExerciseViewModel
import com.symphony.mrfit.data.model.Exercise
import org.junit.Assert.*
import org.junit.Before

import org.junit.Test

class CustomExercisesActivityTest {
//behavioral
//TODO
@Test
fun onCreate() {
}
@Test
fun onStart() {
}
@Test
fun onSupportNavigateUp() {
}
@Test
fun deleteExercise(){
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.symphony.mrfit.ui

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.ext.junit.rules.activityScenarioRule
import org.junit.Rule
import org.junit.Test
import com.symphony.mrfit.R




class GoalsActivityTest {
@get:Rule
var activityScenarioRule = activityScenarioRule<GoalsActivity>()

//TODO
@Test
fun checkActivityVisibility() {
}
}

31 changes: 31 additions & 0 deletions app/src/androidTest/java/com/symphony/mrfit/ui/HelperTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.symphony.mrfit.ui

import android.app.Activity
import android.view.View
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.google.android.material.snackbar.Snackbar
import org.hamcrest.CoreMatchers.*
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import java.util.*


class HelperTest{
private lateinit var activity: Activity

//test functionality of calendar method
@Test
fun toCalendarconvertsDatetoCalendar() {
val date = Date()
val cal = Helper.toCalendar(date)
assertThat(cal.get(Calendar.YEAR), `is`(Calendar.getInstance().get(Calendar.YEAR)))
assertThat(cal.get(Calendar.MONTH), `is`(Calendar.getInstance().get(Calendar.MONTH)))
assertThat(cal.get(Calendar.DAY_OF_MONTH), `is`(Calendar.getInstance().get(Calendar.DAY_OF_MONTH))
)
}
}

0 comments on commit f90150a

Please sign in to comment.