Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ android {
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "com.tobioyelekan.dogbreed.testing.DogBreedTestRunner"
vectorDrawables {
useSupportLibrary = true
}
buildConfigField("String", "BASE_URL", "\"https://dog.ceo/api/\"")

testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}

buildTypes {
Expand Down Expand Up @@ -48,7 +54,14 @@ android {
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += setOf(
"/META-INF/{AL2.0,LGPL2.1}",
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md",
"META-INF/DEPENDENCIES",
"META-INF/NOTICE",
"META-INF/LICENSE"
)
}
}
}
Expand All @@ -65,5 +78,24 @@ dependencies {

implementation(libs.hilt.compose)
implementation(libs.hilt.core)
implementation(libs.androidx.test.core)
ksp(libs.hilt.compiler)

kspTest(libs.hilt.compiler)
kspAndroidTest(libs.hilt.compiler)

debugImplementation(libs.compose.test.manifest)
debugImplementation(libs.hilt.android.testing)

androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.hilt.android.testing)
androidTestImplementation(libs.compose.ui.test)
androidTestImplementation(libs.android.junit)
androidTestImplementation(project(":core:database"))
androidTestImplementation(project(":core:network"))
androidTestImplementation(project(":core:testing"))

androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.rules)
androidTestImplementation(libs.espresso.core)
}
230 changes: 230 additions & 0 deletions app/src/androidTest/java/com/tobioyelekan/dogbreed/NavTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
//package com.tobioyelekan.dogbreed
//
//import androidx.compose.ui.test.ExperimentalTestApi
//import androidx.compose.ui.test.assertIsDisplayed
//import androidx.compose.ui.test.hasText
//import androidx.compose.ui.test.junit4.createAndroidComposeRule
//import androidx.compose.ui.test.onAllNodesWithTag
//import androidx.compose.ui.test.onFirst
//import androidx.compose.ui.test.onNodeWithContentDescription
//import androidx.compose.ui.test.onNodeWithTag
//import androidx.compose.ui.test.onNodeWithText
//import androidx.compose.ui.test.performClick
//import com.tobioyelekan.dogbreed.core.database.dao.DogBreedDao
//import com.tobioyelekan.dogbreed.core.network.FakeDogBreedApiService
//import dagger.hilt.android.testing.HiltAndroidRule
//import dagger.hilt.android.testing.HiltAndroidTest
//import kotlinx.coroutines.runBlocking
//import org.junit.Before
//import org.junit.Rule
//import org.junit.Test
//import javax.inject.Inject
//
//@HiltAndroidTest
//@OptIn(ExperimentalTestApi::class)
//class NavTest {
//
// @get:Rule(order = 0)
// val hiltRule = HiltAndroidRule(this)
//
// @get:Rule(order = 1)
// val composeTestRule = createAndroidComposeRule<MainActivity>()
//
// @Inject
// lateinit var dogBreedDao: DogBreedDao
//
// @Before
// fun setUp() {
// hiltRule.inject()
//
// runBlocking {
// FakeDogBreedApiService.allBreedAPIErrorOccurred = false
// FakeDogBreedApiService.subbreedAPIErrorOccurred = false
// dogBreedDao.nukeTable()
// }
// }
//
// @Test
// fun canSeeBreedsScreen() {
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// //can see a breed
// onNodeWithText("affenpinscher").assertIsDisplayed()
// }
// }
//
// @Test
// fun canSeeBreedsScreen_errorOccurred() {
// FakeDogBreedApiService.allBreedAPIErrorOccurred = true
//
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithTag("ErrorScreen").assertIsDisplayed()
// }
// }
//
// @Test
// fun addDogBreedToFavorites() {
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithText("affenpinscher").performClick()
//
// //breedDetails
// waitUntilAtLeastOneExists(hasText("Affenpinscher"))
// onNodeWithContentDescription("click to add breed as favorite")
// .assertIsDisplayed()
//
// //click on add favorites
// onNodeWithContentDescription("click to add breed as favorite")
// .performClick()
// onNodeWithContentDescription("click to remove breed as favorite")
// .assertIsDisplayed()
//
// //click back
// onNodeWithContentDescription("navUp").performClick()
//
// //see breedDetails
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithText("affenpinscher").performClick()
//
// //confirm still favorite
// waitUntilAtLeastOneExists(hasText("Affenpinscher"))
// onNodeWithContentDescription("click to remove breed as favorite")
// .assertIsDisplayed()
// }
// }
//
// @Test
// fun removeDogBreedFromFavorites() {
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
//
// runBlocking {
// dogBreedDao.updateBreed("affenpinscher", true)
// }
//
// onNodeWithText("affenpinscher").performClick()
//
// //breedDetails
// waitUntilAtLeastOneExists(hasText("Affenpinscher"))
// onNodeWithContentDescription("click to remove breed as favorite")
// .assertIsDisplayed()
//
// //click to remove favorites
// onNodeWithContentDescription("click to remove breed as favorite")
// .performClick()
// onNodeWithContentDescription("click to add breed as favorite")
// .assertIsDisplayed()
//
// //click back
// onNodeWithContentDescription("navUp").performClick()
//
// //see all breeds
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithText("affenpinscher").performClick()
//
// //confirm removed
// waitUntilAtLeastOneExists(hasText("Affenpinscher"))
// onNodeWithContentDescription("click to add breed as favorite")
// .assertIsDisplayed()
// }
// }
//
// @Test
// fun canSeeFavoritesScreen() {
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("Favorites"))
//
// runBlocking {
// dogBreedDao.updateBreed("australian", true)
// }
//
// //move to fav
// onNodeWithText("Favorites").performClick()
//
// //confirm australian exists in fav
// onNodeWithText("australian").assertIsDisplayed()
//
// //remove australian from favorites
// onNodeWithText("australian").performClick()
//
// //breed details
// waitUntilAtLeastOneExists(hasText("Australian"))
// onNodeWithContentDescription("click to remove breed as favorite")
// .performClick()
//
// //navUp
// onNodeWithContentDescription("navUp").performClick()
//
// //confirm removed from favList
// waitUntilAtLeastOneExists(hasText("Favorites"))
// onNodeWithText("No favorites breed found \nClick the fav icon on dog details screen")
// .assertIsDisplayed()
// }
// }
//
// @Test
// fun clickOnABreedShouldSeeBreedDetailsScreen_NoSubBreedsListed() {
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithText("affenpinscher").performClick()
//
// //breedDetails
// waitUntilAtLeastOneExists(hasText("Affenpinscher"))
// onNodeWithText("No sub breeds listed").assertIsDisplayed()
// }
// }
//
// @Test
// fun clickOnABreedShouldSeeBreedDetailsScreen_SubBreedsListed() {
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithText("australian").performClick()
//
// //breedDetails
// waitUntilAtLeastOneExists(hasText("Australian"))
// onNodeWithText("Sub breeds").assertIsDisplayed()
//
// //click on a subbreed
// onNodeWithText("shepherd").performClick()
//
// //subbreed screen
// waitUntilAtLeastOneExists(hasText("Australian Shepherd"))
// onAllNodesWithTag("subBreedImageItem")
// .onFirst()
// .assertExists()
// }
// }
//
// @Test
// fun clickOnABreedShouldSeeBreedDetailsScreen_SubBreedsListed_errorOccurred() {
// FakeDogBreedApiService.subbreedAPIErrorOccurred = true
//
// composeTestRule.apply {
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// onNodeWithText("australian").performClick()
//
// //breedDetails
// waitUntilAtLeastOneExists(hasText("Australian"))
// onNodeWithText("Sub breeds").assertIsDisplayed()
// onNodeWithContentDescription("click to add breed as favorite")
// .assertIsDisplayed()
//
// //click on a subbreed
// onNodeWithText("shepherd").performClick()
//
// //subbreed screen
// waitUntilAtLeastOneExists(hasText("Australian Shepherd"))
// onNodeWithTag("ErrorScreen").assertIsDisplayed()
//
// //nav back to details
// onNodeWithContentDescription("navUp").performClick()
// waitUntilAtLeastOneExists(hasText("Australian"))
//
// //nav back to home
// onNodeWithContentDescription("navUp").performClick()
// waitUntilAtLeastOneExists(hasText("All Breeds"))
// waitUntilAtLeastOneExists(hasText("Favorites"))
// }
// }
//}
Loading