-
Notifications
You must be signed in to change notification settings - Fork 0
テストを追加 #26
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
テストを追加 #26
Conversation
|
Warning Rate limit exceeded@harutiro has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 22 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
""" Walkthroughこのプルリクエストは、GitHub Actionsワークフロー、README、ビルド設定、およびユニットテストに関する重要な変更を導入しています。ワークフローは、Ktlintチェックとユニットテストのためのジョブを明確に分離し、README.mdにはユニットテストに関する新しいセクションが追加されました。アプリのビルド設定では、Mockitoライブラリの依存関係が追加され、GitHubサービスに関する包括的なユニットテストが実装されました。 Changes
Sequence DiagramsequenceDiagram
participant Developer
participant GitHub Actions
participant Ktlint
participant UnitTest
Developer->>GitHub Actions: プッシュ/プルリクエスト
GitHub Actions->>Ktlint: コードスタイルチェック
GitHub Actions->>UnitTest: ユニットテスト実行
Ktlint-->>GitHub Actions: チェック結果
UnitTest-->>GitHub Actions: テスト結果
Possibly related PRs
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
app/build.gradle (1)
Line range hint
15-15: SDKバージョンとライブラリバージョンの検証が必要以下の点について確認が必要です:
compileSdk 35とtargetSdk 35は現時点で存在しない将来のバージョンです- 複数のライブラリバージョンが現在リリースされている最新版より進んでいます:
- androidx.core:core-ktx:1.15.0
- androidx.appcompat:appcompat:1.7.0
- その他
安定版のSDKとライブラリバージョンに修正することを推奨します。現在の安定版を確認するには、以下のコマンドを実行してください:
#!/bin/bash # Description: Verify latest stable versions of Android SDK and libraries # Check latest stable Android SDK version sdkmanager --list | grep -A 5 "Installed packages:" | grep "platforms;" # Check latest versions of androidx libraries curl -s https://dl.google.com/dl/android/maven2/androidx/core/core-ktx/maven-metadata.xml | grep -oP "(?<=<version>)[^<]+(?=</version>)" | tail -n 1 curl -s https://dl.google.com/dl/android/maven2/androidx/appcompat/appcompat/maven-metadata.xml | grep -oP "(?<=<version>)[^<]+(?=</version>)" | tail -n 1Also applies to: 41-50
🧹 Nitpick comments (7)
app/src/test/kotlin/jp/co/yumemi/android/code_check/features/github/GitHubServiceUsecaseImplTest.kt (2)
48-68: モックデータの構造化を推奨しますテストの可読性と再利用性を向上させるため、モックデータをコンパニオンオブジェクトまたは別のテストデータクラスに移動することを提案します。
+ companion object { + private fun createMockRepositoryItem( + name: String, + ownerIconUrl: String, + language: String, + ) = RepositoryItem( + name = name, + ownerIconUrl = ownerIconUrl, + language = language, + stargazersCount = 100, + forksCount = 50, + openIssuesCount = 30, + watchersCount = 70, + ) + }
31-43: エッジケースのテストを追加することを推奨します現在のテストケースは基本的なシナリオのみをカバーしています。以下のようなエッジケースのテストを追加することを推奨します:
- 空文字列での検索
- 特殊文字を含む検索クエリ
- 検索結果が0件の場合
app/src/test/kotlin/jp/co/yumemi/android/code_check/features/github/GitHubServiceRepositoryImplTest.kt (2)
30-46: 成功ケースのアサーションを強化することを推奨します現在のテストでは基本的なフィールドのみを検証しています。以下のような追加のアサーションを推奨します:
- 言語フィールドの検証
- Star数、Watcher数、Fork数、Issue数の検証
- 2番目のアイテムの検証
99-124: モックデータ生成関数の改善を推奨しますモックデータ生成をより柔軟にするため、以下の改善を提案します:
- パラメータ化されたファクトリメソッドの作成
- テストデータのバリエーションの追加
- private fun mockRepositoryList(): RepositoryList { + private fun mockRepositoryList( + itemCount: Int = 2, + baseStarCount: Int = 100 + ): RepositoryList {.github/workflows/check_workflow.yaml (1)
18-30: テストワークフローの強化を推奨します以下の機能を追加することで、テストの可視性と品質管理を向上させることができます:
- テスト結果のGitHubアクションへの報告
- テストカバレッジレポートの生成と保存
test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Change Permission run: chmod +x ./gradlew - name: Execute Unit Tests - run: ./gradlew test + run: ./gradlew test jacocoTestReport + - name: Upload Test Results + uses: actions/upload-artifact@v4 + if: always() + with: + name: test-results + path: app/build/test-results + + - name: Upload Coverage Report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: app/build/reports/jacocoREADME.md (1)
42-52: テストドキュメントの拡充を推奨しますユニットテストのセクションに以下の情報を追加することを推奨します:
- テストの方針と戦略
- カバレッジの要件
- テストの構成ガイドライン
- モックの使用方針
### Unitテストについて - Hilt, JUnit, Mockitoを持ちいてUnitテストを作成しました。 + +#### テスト方針 +- ビジネスロジックは100%のカバレッジを目指す +- リポジトリレイヤーは主要なエラーケースを網羅 +- UIレイヤーはクリティカルなユーザーフローのみテスト + +#### テストの構成 +- テストクラスは対象クラスと同じパッケージに配置 +- テストメソッド名は`given_when_then`形式で記述 +- モックは必要最小限に留めるapp/build.gradle (1)
69-71: Mockitoの依存関係の追加を承認テスト実装のためのMockito依存関係の追加は適切です。ただし、以下の改善を提案します:
- mockito-coreとmockito-inlineのバージョンを揃えることで、互換性の問題を防ぐことができます
- 最新の安定版を使用することを推奨します
- testImplementation "org.mockito:mockito-core:4.6.1" - testImplementation 'org.mockito:mockito-inline:5.2.0' + testImplementation "org.mockito:mockito-core:5.2.0" + testImplementation 'org.mockito:mockito-inline:5.2.0'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/check_workflow.yaml(2 hunks)README.md(1 hunks)app/build.gradle(1 hunks)app/src/test/kotlin/jp/co/yumemi/android/code_check/features/github/GitHubServiceRepositoryImplTest.kt(1 hunks)app/src/test/kotlin/jp/co/yumemi/android/code_check/features/github/GitHubServiceUsecaseImplTest.kt(1 hunks)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.github/workflows/check_workflow.yaml (2)
18-43: テストジョブの実装について改善の提案があります。現在の実装は良い基盤となっていますが、以下の改善を推奨します:
ktlintジョブとの依存関係を設定することで、コードスタイルチェック後にテストを実行する- GitHub Actionsの
Test Report機能を活用してテスト結果を可視化する- コードカバレッジの最低閾値を設定する
以下の変更を提案します:
test: runs-on: ubuntu-latest + needs: ktlint steps: - uses: actions/checkout@v4 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Change Permission run: chmod +x ./gradlew - name: Execute Unit Tests run: ./gradlew test jacocoTestReport + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() + with: + report_paths: 'app/build/test-results/test/TEST-*.xml' - name: Upload Test Results uses: actions/upload-artifact@v4 if: always() with: name: test-results path: app/build/test-results - name: Upload Coverage Report uses: actions/upload-artifact@v4 with: name: coverage-report path: app/build/reports/jacoco + - name: Check Coverage + run: | + MIN_COVERAGE=80 + COVERAGE=$(./gradlew jacocoTestCoverageVerification) + if [ $? -ne 0 ]; then + echo "コードカバレッジが${MIN_COVERAGE}%未満です" + exit 1 + fi
1-3: ワークフロー全体の設定について改善を提案します。タイムアウトと同時実行の制限を追加することで、より堅牢なワークフローになります:
name: Run Gradle on PRs on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs:また、各ジョブに
timeout-minutesを設定することを推奨します:ktlint: runs-on: ubuntu-latest + timeout-minutes: 10 steps: test: runs-on: ubuntu-latest + timeout-minutes: 15 steps:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/check_workflow.yaml(2 hunks)app/build.gradle(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- app/build.gradle
🔇 Additional comments (1)
.github/workflows/check_workflow.yaml (1)
Line range hint
4-17: ジョブ名とステップ名の変更が適切です!ジョブ名を
gradleからktlintに変更したことで、このジョブの目的がより明確になりました。また、実行ステップの名前も具体的になり、メンテナンス性が向上しています。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
app/build.gradle (2)
89-92: コメントアウトされたコードは削除することを推奨します不要なコメントアウトされたコードは、可読性を低下させる可能性があります。必要ない場合は削除することをお勧めします。
102-104: ファイルフィルターの拡張を推奨します現在のファイルフィルターに以下を追加することを検討してください:
- Daggerが生成するコード
- Hiltが生成するコード
- データバインディングが生成するコード
- def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*'] + def fileFilter = [ + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/*Test*.*', + '**/Hilt_*.*', + '**/*_Factory.*', + '**/*_MembersInjector.*', + '**/DataBinding*.*' + ]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/check_workflow.yaml(2 hunks)app/build.gradle(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/check_workflow.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (3)
app/build.gradle (3)
9-9: コードカバレッジ計測のためのJacocoプラグインが適切に追加されています!
70-71: Mockitoの依存関係が適切に追加されています!mockito-coreとmockito-inlineの両方が追加されており、Kotlinでのモックテストに必要な設定が完了しています。
Line range hint
43-54: 依存関係のバージョン番号の確認が必要です以下の依存関係のバージョン番号が現在利用可能なものより高くなっています:
- androidx.core:core-ktx:1.15.0
- androidx.appcompat:appcompat:1.7.0
- androidx.constraintlayout:constraintlayout:2.2.0
- androidx.recyclerview:recyclerview:1.4.0
- androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7
- androidx.navigation:navigation-fragment-ktx:2.8.5
これらのバージョンが実際に存在するか確認してください。
app/build.gradle
Outdated
| sourceDirectories.setFrom(files([mainSrc])) | ||
| classDirectories.setFrom(files([debugTree])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Kotlinのソースディレクトリの追加を推奨します
現在の設定ではJavaのソースディレクトリのみが含まれています。Kotlinのソースも含めるために、以下の修正を推奨します:
- sourceDirectories.setFrom(files([mainSrc]))
+ sourceDirectories.setFrom(files([
+ mainSrc,
+ "$projectDir/src/main/kotlin"
+ ]))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| sourceDirectories.setFrom(files([mainSrc])) | |
| classDirectories.setFrom(files([debugTree])) | |
| sourceDirectories.setFrom(files([ | |
| mainSrc, | |
| "$projectDir/src/main/kotlin" | |
| ])) | |
| classDirectories.setFrom(files([debugTree])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harutiro ご対応ありがとうございます!変更が正しく実装されていることを確認しました。
⟦(。◝ᴗ◜。)⟧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/build.gradle (2)
9-9: プラグインのバージョンを明示することを推奨します再現性のある確実なビルドを保証するために、jacocoプラグインのバージョンを明示的に指定することをお勧めします。
- id 'jacoco' + id 'jacoco' version '0.8.8'
89-92: コメントアウトされたコードの削除を推奨しますコメントアウトされたコードはリポジトリに残さず、必要な場合はGitの履歴から参照できるようにすることをお勧めします。
-//tasks.withType(Test) { -// useJUnitPlatform() -// finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run -//}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
README.md(1 hunks)app/build.gradle(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (2)
app/build.gradle (2)
70-71: Mockitoの依存関係の追加が適切ですテスト用のMockitoライブラリの追加が適切に行われています。mockito-coreとmockito-inlineの両方が含まれており、Kotlinでのモック作成に必要な依存関係が揃っています。
94-114: Jacocoの設定が適切に構成されていますカバレッジレポートの設定が以下の点で適切に行われています:
- JavaとKotlinの両方のソースディレクトリが含まれている
- 不要なファイル(R.class等)が適切にフィルタリングされている
- XMLとHTMLの両方のレポート形式が有効化されている
概要
テストを追加して、自動で、動作検証を行うように変更
関連Issue
このセクションでは、このPRが関連するIssueやタスクをリンクしてください。以下のように記述します。
変更点
このセクションでは、具体的な変更点や修正箇所を箇条書きでリストアップしてください。
テスト
このセクションでは、このPRに関連するテストケースやテスト方法を記載してください。
Summary by CodeRabbit
新機能
テスト
GitHubServiceRepositoryImplおよびGitHubServiceUsecaseImplに対する新しいテストクラスを追加ドキュメント