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

Feat core testing #14

Merged
merged 27 commits into from
Aug 27, 2024
Merged

Feat core testing #14

merged 27 commits into from
Aug 27, 2024

Conversation

shinhyo
Copy link
Owner

@shinhyo shinhyo commented Aug 27, 2024

  • Add Kover: Introduced the Kover plugin to measure code coverage. (d3555ab, d6bb96c, 9743344)
  • Enable Kover Report on Check: Enabled Kover report generation during code checks. (84d6bd1)

Update dependencies to their latest versions, including:

- Android Gradle Plugin to 8.5.2
- Android Tools
 to 31.5.2
- Kotlin to 2.0.10
- KSP to 2.0.10-1.0.24
- Jetpack Compose to 1.7.0-beta07
- Coil to 2.7.0

- Haze to 0.7.2
This commit migrates all Java files in the project to Kotlin.
This change improves code readability, concis
eness, and maintainability.
Migrate from Gson to Kotlin Serialization for JSON parsing.
This includes updating dependencies, annotations, and data classes
.
Also, enable HttpLoggingInterceptor for debugging in non-production builds.
Updated README.md to reflect the use of Kotlin Serialization in the project.
Update Kotlin version to 2.0.20-RC2 and KSP
 to 2.0.20-RC2-1.0.24.
- Separated image and info states for better data management.
- Improved UI by adding spacing between elements.
- Updated
 chip display for character categories.
- Removed unnecessary list structure in UI state.
This commit updates the character model and UI to improve the user experience.

Specific changes include:

- Removing unnecessary fields
 from the character model.
- Updating the UI to reflect the changes to the character model.
- Improving the layout and styling of the character list and detail screens.
- Fixing a bug that caused the favorite icon to not be displayed correctly.
This commit updates the kotlinxSerializationJson library to version 1.7.1.
This commit updates the project to use Jetpack Compose Navigation 2
.8.0-beta07 and migrates the navigation logic to use the new `composable<T>` API.

Specific changes include:

- Updating the `androidxNavigation` version in `gradle/libs.versions.toml`.
- Replacing the old `composable` calls with `composable
<T>` in `BottomBarNavigation.kt` and `DetailNavigation.kt`.
- Updating the `DetailViewModel` to retrieve arguments using the new API.
- Updating the `BrbaApp` to use the new `bottomBarComposable` function.
- Applying the `org.jetbrains.kotlin.plugin.serialization` plugin to the feature modules.
- Adding the `kotlinx.serialization.json` dependency to the feature modules.
This commit updates the Kotlin version used in the project to 2.0
.20-RC2. It also updates the corresponding badge in the README.md file.
This commit adds the character description to the detail screen, displaying it below the character's nickname and category chips.

Specific changes include:

- Adding a `description` field to the `CharacterResponse` and `BrbaCharacter` models.
- Updating the RetrofitNetwork to ignore unknown keys when parsing JSON responses.
- Modifying the DetailScreen to display the character description in a Text composable.
- Adjusting the
 layout of the DetailScreen to accommodate the new description field.
This commit disables the debuggable flag in debug builds and fixes an issue with character ratios.

The debuggable flag is now set to false for debug builds, preventing accidental debugging in production.

The character ratio calculation has been improved to ensure consistency and avoid potential issues.
This commit introduces a new composable function called `BrbaChips` for displaying a list of chips.

The
 `BrbaChips` composable takes a list of strings and displays them as chips with rounded corners, a border, and a background color. It is used in the `DetailScreen` to display the categories of a character.

This change improves the UI by providing a consistent and visually appealing way to display chips.
This commit introduces a new module, `core:testing`, to the project. This module provides testing utilities and dependencies for
 other modules.

The following changes were made:

- Created the `core:testing` module with a basic build configuration.
- Added dependencies on other core modules and testing libraries.
- Included the module in the project's settings.
- Added a `.gitignore` file and `proguard-
rules.pro` file for the module.
- Updated the `libs.versions.toml` file to include the `kotlinx-coroutines-test` dependency.
This commit moves files related to the list and setting features to their respective feature packages.

- ListViewModel.
kt is moved from feature/main to feature/list.
- SettingNavigation.kt is moved from feature/main/navigation to feature/setting/navigation.
- SettingScreen.kt is moved from feature/main to feature/setting.
- ListNavigation.kt is moved from feature/main/navigation
 to feature/list/navigation.
- SettingViewModel.kt is moved from feature/main to feature/setting.
- ListScreen.kt is moved from feature/main to feature/list.

This change improves the organization of the codebase and makes it easier to maintain.
This commit adds the necessary infrastructure for unit testing ViewModels.

- Added dependencies for testing: MockK, Turbine, and
 JUnit.
- Created a base class for ViewModel tests (`BaseViewModelTest`) to provide common setup and dependencies.
- Created a test rule (`MainDispatcherRule`) to manage the main dispatcher for testing.
- Added a sample test for the `ListViewModel`.
This commit adds unit tests for the ListViewModel, covering the following scenarios:

- Fetching character list and device
 data on creation
- Toggling favorite status of a character
- Changing the theme mode
- Handling exceptions when changing the theme from system mode
Update Kotlin to 2.0.20, KSP to 2.0.20-1.0.
24, and Jetpack Compose to 2024.08.00.
- Refactor ListViewModelTest to use Given-When-Then style for better readability.
- Add a test case to
 handle RuntimeException when fetching character list.
- Move default mock data setup to BaseViewModelTest for reusability.
Added unit tests for FavoriteViewModel to verify its behavior in different scenarios, including:
- Initial state is Loading

- Success state with data when favorites exist
- Error state when getFavoriteListUseCase throws an exception
- Empty state when no favorites exist
- Invocation of updateFavoriteUseCase when onFavoriteClick is called

Also, renamed `updateFavorite` function to `onFavoriteClick` for clarity.
This commit adds kover to the project for code coverage analysis.

- Adds kover dependency to the build logic
.
- Configures kover for Android modules, including filters for specific classes and variants.
- Applies kover plugin to feature modules.
…raintlayoutCompose

This commit updates the version of androidDes
ugarJdkLibs to 2.1.0 and removes the dependency on androidxConstraintlayoutCompose.
Apply spotless formatting to the codebase.
This commit adds kover to the project for code coverage analysis and integrates it with the CI workflow.

- Adds
 kover dependency and configuration for Android modules.
- Includes a step to generate kover XML reports in the build workflow.
- Utilizes the madrapps/jacoco-report action to display test coverage and enforce minimum coverage thresholds.
- Adjusts the build trigger to run on pull requests instead of pushes
 to the develop branch.
- Reduces the build timeout to 30 minutes.
Copy link

github-actions bot commented Aug 27, 2024

test coverage report

Overall Project 42.49% -19.48% 🍏
Files changed 13.54%

Module Coverage
Kover Gradle Plugin XML report for :feature:list 88.73% 🍏
Kover Gradle Plugin XML report for :feature:favorite 87.3% 🍏
Kover Gradle Plugin XML report for :feature:detail 0% -66.4%
Kover Gradle Plugin XML report for :feature:main 0% 🍏
Kover Gradle Plugin XML report for :feature:setting 0% 🍏
Files
Module File Coverage
Kover Gradle Plugin XML report for :feature:list ListViewModel.kt 88.73% 🍏
Kover Gradle Plugin XML report for :feature:favorite FavoriteViewModel.kt 87.3% 🍏
Kover Gradle Plugin XML report for :feature:detail DetailViewModel.kt 0% -66.4%
Kover Gradle Plugin XML report for :feature:main MainViewModel.kt 0% 🍏
Kover Gradle Plugin XML report for :feature:setting SettingViewModel.kt 0% 🍏

This commit updates the jacoco-report action to v1.6.1
 and fixes the path to the kover report in the workflow.

The updated path now points to the correct location of the kover report within the feature modules. This ensures that the coverage report is generated correctly and displayed in the workflow.
This commit adds kover to the project for code coverage analysis and updates the README to reflect the changes.

- Adds kover dependency to the build logic.
- Updates README with information about kover.
@shinhyo shinhyo marked this pull request as ready for review August 27, 2024 01:57
@shinhyo shinhyo merged commit 8f9c6ab into develop Aug 27, 2024
1 check passed
@shinhyo shinhyo deleted the feat_core_testing branch August 27, 2024 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant