Skip to content

Commit

Permalink
Add detail screen test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexymumo committed Mar 17, 2024
1 parent 4a0a352 commit 74de9f4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 49 deletions.
1 change: 1 addition & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ 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
android.nonTransitiveRClass=true
android.enableJetifier=true
16 changes: 9 additions & 7 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ android {

testOptions {
unitTests {
isIncludeAndroidResources = false
isIncludeAndroidResources = true
}
}

packaging {
resources.excludes.addAll(
listOf(
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md"
)
)
}
buildTypes {
release {
isMinifyEnabled = false
Expand Down Expand Up @@ -112,8 +119,6 @@ dependencies {
// Splash - Screen
implementation(libs.splash.screen)

// Roboelectric
implementation(libs.roboelectric)

// Hilt
implementation(libs.dagger.hilt)
Expand All @@ -124,9 +129,6 @@ dependencies {
androidTestImplementation(libs.junit.ext)
debugImplementation(libs.compose.ui.test.manifest)




}


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ fun DetailScreen(
maxLines = 1,
fontSize = 16.sp,
color = Color.Green,
text = convertStringToDate(article.publishedAt ?: "UnKnown")
text = article.publishedAt ?: "Uknown"
//text = convertStringToDate(article.publishedAt ?: "UnKnown")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.alexmumo.presentation.detail

import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.navigation.compose.rememberNavController
import com.alexmumo.domain.model.Article
import com.alexmumo.domain.model.Source
import com.alexmumo.domain.repository.BookMarkRepository
import com.alexmumo.presentation.bookmarks.BookMarkViewModel
import io.mockk.mockk
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowLog


@RunWith(RobolectricTestRunner::class)
@Config(instrumentedPackages = ["androidx.loader.content"], sdk = [33])
class DetailScreenTest {
@get:Rule
val composeRule = createComposeRule()

private val bookMarkRepository = mockk<BookMarkRepository>(relaxed = true)
private val viewModel = BookMarkViewModel(bookMarkRepository = bookMarkRepository)

@Before
@Throws(Exception::class)
fun setUp() {
ShadowLog.stream = System.out
}

@Test
fun testDetailLayout() {
composeRule.setContent {
DetailScreen(navController = rememberNavController(), viewModel = viewModel, article = Article(author = null, content = null,description = null,publishedAt = null, Source(id = null, name = ""),title = null, url = "", urlToImage = null ))
}
composeRule.onNodeWithTag("detail_tag").assertExists()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.alexmumo.presentation.home

class HomeScreenTest {

}

class HomeScreenTest

This file was deleted.

0 comments on commit 74de9f4

Please sign in to comment.