-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fa427e
commit a070a3a
Showing
82 changed files
with
5,874 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,12 @@ jobs: | |
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
|
||
- name: Execute Gradle command - testDebugUnitTest | ||
run: ./gradlew testDebugUnitTest | ||
- name: Execute Gradle command - unitTest | ||
run: ./gradlew testDebugUnitTest --continue | ||
|
||
- name: Upload Test Reports | ||
if: ${{ always() }} | ||
uses: actions/[email protected] | ||
with: | ||
name: test-reports | ||
path: '**/build/reports/tests/' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/src/androidTest/java/com/example/harmonyhub/components_test/AlbumCardTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.example.harmonyhub.components_test | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.example.harmonyhub.ui.components.AlbumCard | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AlbumCardTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun albumCard_displaysSongNameAndArtistsCorrectly() { | ||
val songName = "Shape of You" | ||
val albumImg = "https://example.com/sample_image.jpg" | ||
val id = "1" | ||
val listArtist = listOf("Ed Sheeran") | ||
|
||
composeTestRule.setContent { | ||
AlbumCard( | ||
songName = songName, | ||
albumImg = albumImg, | ||
id = id, | ||
listArtist = listArtist | ||
) | ||
} | ||
|
||
// Kiểm tra sự tồn tại của AlbumCard thông qua TestTag | ||
composeTestRule | ||
.onNodeWithTag("AlbumCard") | ||
.assertExists() | ||
|
||
// Kiểm tra hiển thị songName và nghệ sĩ | ||
composeTestRule | ||
.onNodeWithText(songName) | ||
.assertIsDisplayed() | ||
|
||
composeTestRule | ||
.onNodeWithText("Ed Sheeran") | ||
.assertIsDisplayed() | ||
} | ||
|
||
|
||
@Test | ||
fun albumCard_handlesMultipleArtistsCorrectly() { | ||
val songName = "Chìm Sâu" | ||
val albumImg = "https://example.com/sample_image2.jpg" | ||
val id = "2" | ||
val listArtist = listOf("RPT MCK", "Trung Trần") | ||
|
||
composeTestRule.setContent { | ||
AlbumCard( | ||
songName = songName, | ||
albumImg = albumImg, | ||
id = id, | ||
listArtist = listArtist | ||
) | ||
} | ||
|
||
// Kiểm tra danh sách nghệ sĩ ghép đúng | ||
composeTestRule | ||
.onNodeWithText("RPT MCK, Trung Trần") | ||
.assertIsDisplayed() | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
app/src/androidTest/java/com/example/harmonyhub/components_test/ArtistCardTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.example.harmonyhub.components_test | ||
|
||
import androidx.compose.ui.test.assert | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.hasText | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import com.example.harmonyhub.ui.components.ArtistsCard | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
|
||
class ArtistsCardTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
|
||
|
||
} |
37 changes: 37 additions & 0 deletions
37
app/src/androidTest/java/com/example/harmonyhub/components_test/ChartCardTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.example.harmonyhub.components_test | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import com.example.harmonyhub.ui.components.ChartCard | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ChartCardTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testChartCardDisplay() { | ||
val chartImg = "https://example.com/chart_image.jpg" | ||
val chartName = "Top 100 Chart" | ||
val chartId = "1" | ||
|
||
composeTestRule.setContent { | ||
ChartCard( | ||
chartImg = chartImg, | ||
chartName = chartName, | ||
chartId = chartId | ||
) | ||
} | ||
|
||
// Kiểm tra xem ảnh có được tải và hiển thị đúng không | ||
composeTestRule.onNodeWithContentDescription("Photo") | ||
.assertExists() // Kiểm tra nếu ảnh hiển thị | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
app/src/androidTest/java/com/example/harmonyhub/components_test/GenreCardTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.harmonyhub.components_test | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import com.example.harmonyhub.ui.components.GenreCard | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class GenreCardTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testGenreCardDisplay() { | ||
// Thiết lập nội dung cho composable GenreCard | ||
composeTestRule.setContent { | ||
GenreCard(genre = "Pop") | ||
} | ||
|
||
// Kiểm tra xem GenreCard có hiển thị đúng không (bằng cách tìm text trên card) | ||
composeTestRule.onNodeWithText("Pop") | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun testGenreCardClickAction() { | ||
// Thiết lập nội dung cho composable GenreCard | ||
composeTestRule.setContent { | ||
GenreCard(genre = "Pop") | ||
} | ||
|
||
// Kiểm tra hành động nhấp vào card | ||
composeTestRule.onNodeWithText("Pop") | ||
.performClick() | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
app/src/androidTest/java/com/example/harmonyhub/components_test/PlaylistCardTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//package com.example.harmonyhub.components_test | ||
// | ||
//import androidx.compose.ui.test.assertIsDisplayed | ||
//import androidx.compose.ui.test.junit4.createComposeRule | ||
//import androidx.compose.ui.test.onNodeWithText | ||
//import androidx.compose.ui.test.performClick | ||
//import com.example.harmonyhub.ui.components.PlaylistCard | ||
//import com.example.harmonyhub.ui.components.Playlist | ||
//import org.junit.Rule | ||
//import org.junit.Test | ||
// | ||
//class PlaylistCardTest { | ||
// | ||
// @get:Rule | ||
// val composeTestRule = createComposeRule() | ||
// | ||
// @Test | ||
// fun testPlaylistCardDisplay() { | ||
// // Thiết lập nội dung cho composable PlaylistCard | ||
// val playlist = Playlist(name = "Top Hits", img = com.example.harmonyhub.R.drawable.v) | ||
// composeTestRule.setContent { | ||
// PlaylistCard(playlist = playlist, onClick = {}) | ||
// } | ||
// | ||
// // Kiểm tra xem tên playlist có hiển thị trên card không | ||
// composeTestRule.onNodeWithText("Top Hits") | ||
// .assertIsDisplayed() | ||
// } | ||
// | ||
// @Test | ||
// fun testPlaylistCardClickAction() { | ||
// // Thiết lập nội dung cho composable PlaylistCard | ||
// val playlist = Playlist(name = "Top Hits", img = com.example.harmonyhub.R.drawable.v) | ||
// var clicked = false | ||
// composeTestRule.setContent { | ||
// PlaylistCard(playlist = playlist, onClick = { clicked = true }) | ||
// } | ||
// | ||
// // Mô phỏng hành động nhấp vào card | ||
// composeTestRule.onNodeWithText("Top Hits") | ||
// .performClick() | ||
// | ||
// // Kiểm tra xem hành động nhấp vào có được thực thi không | ||
// assert(clicked) | ||
// } | ||
//} |
Oops, something went wrong.