Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Codecov #22

Merged
merged 15 commits into from
Mar 24, 2024
6 changes: 6 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
- name: Build with Gradle
run: ./gradlew build

- name: Upload coverage report to CodeCov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: alexymumo/News-App

- name: Upload a build artifact
uses: actions/[email protected]
with:
Expand Down
27 changes: 27 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

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

33 changes: 21 additions & 12 deletions .idea/deploymentTargetDropDown.xml

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

5 changes: 2 additions & 3 deletions .idea/gradle.xml

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

10 changes: 10 additions & 0 deletions .idea/migrations.xml

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

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![codecov](https://codecov.io/gh/alexymumo/News-App/graph/badge.svg?token=15AJMIDLLE)](https://codecov.io/gh/alexymumo/News-App)

## News-App
- News App is a multi-module news app built using Kotlin, Jetpack Compose and [News API]("https://newsapi.org/")

Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ android {
"proguard-rules.pro"
)
}
debug {
enableAndroidTestCoverage = true
enableUnitTestCoverage = true
}
}

compileOptions {
Expand Down
21 changes: 12 additions & 9 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,17 @@ dependencies {

implementation(libs.android.core)
implementation(libs.android.appcompat)
testImplementation(libs.junit)
androidTestImplementation(libs.expresso.core)
androidTestImplementation(libs.truth)
testImplementation(libs.truth)
androidTestImplementation(libs.core.testing)
implementation(libs.junit.androidx.ktx)
implementation(libs.core.ktx)
implementation(libs.core.test)

// Paging
implementation(libs.paging.runtime)

// Robolectric
testImplementation(libs.roboelectric)

// Coroutine
implementation(libs.bundles.coroutine)

// Room
testImplementation(libs.room.testing)
implementation(libs.room.paging)
implementation(libs.room.ktx)
api(libs.room.runtime)
Expand All @@ -69,4 +61,15 @@ dependencies {
// Hilt
implementation(libs.dagger.hilt)
kapt(libs.hilt.compiler)


testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.room.testing)
testImplementation(libs.roboelectric)

androidTestImplementation(libs.core.testing)
androidTestImplementation(libs.expresso.core)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.junit)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2024 News-App
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alexmumo.database.db

import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.alexmumo.database.dao.ArticleDao
import com.alexmumo.database.dao.BookMarkDao
import com.alexmumo.database.dao.RemoteKeyDao
import com.alexmumo.database.entity.ArticleEntity
import com.alexmumo.database.entity.SourceEntity
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
class NewsDatabaseTest {

private lateinit var articleDao: ArticleDao
private lateinit var bookMarkDao: BookMarkDao
private lateinit var remoteKeyDao: RemoteKeyDao
private lateinit var newsDatabase: NewsDatabase

@Before
fun setUpDatabase() {
val context = ApplicationProvider.getApplicationContext<Context>()
newsDatabase = Room.inMemoryDatabaseBuilder(
context,
NewsDatabase::class.java
).build()
}

@Test
fun saveArticles_returns_a_listOf_articles() = runTest {
articleDao.saveArticles(articles)
val articles = articleDao.pagingSource()
assertThat(articles).isNotNull()
}

@Test
fun deleteArticles_returns_null() = runTest {
articleDao.saveArticles(articles)
val articles = articleDao.deleteArticles()
assertThat(articles).isNull()
}

@After
fun closeDatabase() {
newsDatabase.close()
}

companion object {
private val article = ArticleEntity(author = null, content = null, description = null, publishedAt = null, title = null, SourceEntity(id = null, name = ""), url = "", urlToImage = null)
val articles = listOf(article)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2024 News-App
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alexmumo.datastore

class NewsPreferenceTest
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 News-App
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alexmumo.presentation.data

import com.alexmumo.domain.model.Article
import com.alexmumo.domain.model.Source

val article = Article(
author = null,
content = null,
description = null,
publishedAt = null,
source = Source(
id = null,
name = ""
),
title = null,
url = "",
urlToImage = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fun BookMarkScreen(
Scaffold(
topBar = {
TopAppBar(
modifier = Modifier.testTag("top_app_bar_test_tag"),
title = {
Text(
text = "BookMarks",
Expand Down
Loading
Loading