From 12d9530bd2c1ef1ccc484fba91c51416bbcf3a36 Mon Sep 17 00:00:00 2001 From: lan Date: Sun, 8 Dec 2024 16:43:08 +0700 Subject: [PATCH 1/3] add unit test DefaultHomeScreen --- .../DefaultHomeScreenTest.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/src/test/java/com/example/harmonyhub/defaulthomescreen/DefaultHomeScreenTest.kt diff --git a/app/src/test/java/com/example/harmonyhub/defaulthomescreen/DefaultHomeScreenTest.kt b/app/src/test/java/com/example/harmonyhub/defaulthomescreen/DefaultHomeScreenTest.kt new file mode 100644 index 0000000..b0c5270 --- /dev/null +++ b/app/src/test/java/com/example/harmonyhub/defaulthomescreen/DefaultHomeScreenTest.kt @@ -0,0 +1,28 @@ +import com.example.harmonyhub.data.network.* +import com.example.harmonyhub.data.network.Response +import com.example.harmonyhub.data.repository.DefaultHomeScreenRepo +import kotlinx.coroutines.runBlocking +import okhttp3.* +import org.junit.Assert.* +import org.junit.Before +import org.junit.Test +import java.io.IOException + +class DefaultHomeScreenRepoTest { + + private lateinit var repo: DefaultHomeScreenRepo + + @Before + fun setUp() { + repo = DefaultHomeScreenRepo() + } + + @Test + fun `test updatePopularItem success`() = runBlocking { + var result = repo.updatePopularItem() + assertNotNull(result) + assertEquals(result!!.listPopularAlbums!!.size, 9) + assertEquals(result!!.listPopularArtist!!.size, 10) + assertEquals(result!!.listChart!!.size, 6) + } +} From d4c3514d74ccb6e65117288852d70433c551a459 Mon Sep 17 00:00:00 2001 From: Hoang Lan Le <68813268+nalgnaohel@users.noreply.github.com> Date: Sun, 8 Dec 2024 17:27:42 +0700 Subject: [PATCH 2/3] Update test_debug.yml Signed-off-by: Hoang Lan Le <68813268+nalgnaohel@users.noreply.github.com> --- .github/workflows/test_debug.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_debug.yml b/.github/workflows/test_debug.yml index 6d5d5de..c3ae7a5 100644 --- a/.github/workflows/test_debug.yml +++ b/.github/workflows/test_debug.yml @@ -23,4 +23,11 @@ jobs: run: chmod +x ./gradlew - name: Execute Gradle command - unitTest - run: ./gradlew testDebugUnitTest + run: ./gradlew testDebugUnitTest --continue + + - name: Upload Test Reports + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: test-reports + path: '**/build/reports/tests/' From fd54f201d77229b0d288a29ddd5aca10420828a2 Mon Sep 17 00:00:00 2001 From: Hoang Lan Le <68813268+nalgnaohel@users.noreply.github.com> Date: Sun, 8 Dec 2024 17:29:35 +0700 Subject: [PATCH 3/3] fix upload artifact version test_debug.yml Signed-off-by: Hoang Lan Le <68813268+nalgnaohel@users.noreply.github.com> --- .github/workflows/test_debug.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_debug.yml b/.github/workflows/test_debug.yml index c3ae7a5..7c6d4df 100644 --- a/.github/workflows/test_debug.yml +++ b/.github/workflows/test_debug.yml @@ -27,7 +27,7 @@ jobs: - name: Upload Test Reports if: ${{ always() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4.4.3 with: name: test-reports path: '**/build/reports/tests/'