Skip to content

test: ダイアログテストとUseCaseテストの整備#103

Merged
ai-kurou merged 3 commits into
mainfrom
feature/refactor-unit-test
May 29, 2026
Merged

test: ダイアログテストとUseCaseテストの整備#103
ai-kurou merged 3 commits into
mainfrom
feature/refactor-unit-test

Conversation

@ai-kurou
Copy link
Copy Markdown
Owner

@ai-kurou ai-kurou commented May 29, 2026

Summary

  • RssiThresholdUseCase のユニットテストを新規追加(observe / update の委譲確認)
  • feature/settingsfeature/onboarding のダイアログテストを「表示確認+アクション」と「キャンセルを押す」の2ケース構成に統一
    • BluetoothUnavailableDialog はキャンセルボタンがないため1ケース構成
  • qodana_code_quality.yml を削除し、Qodana ジョブを on-pull-request.yml / on-main-merge.yml に統合

Test plan

  • ./gradlew :core:domain:testDebugUnitTest — RssiThresholdUseCaseTest 通過
  • ./gradlew :feature:settings:testDebugUnitTest — 全ダイアログテスト通過
  • ./gradlew :feature:onboarding:testDebugUnitTest — 全ダイアログテスト通過

🤖 Generated with Claude Code

@codacy-production
Copy link
Copy Markdown
Contributor

codacy-production Bot commented May 29, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · -4 duplication

Metric Results
Complexity 4
Duplication -4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

📝 Walkthrough

Walkthrough

複数のダイアログユニットテストとドメインレイヤーのユースケーステストを統一的に改編しました。従来は UI 表示確認とコールバック検証を別々のテストメソッドで実施していましたが、これらを同一テスト内に統合し、テスト名を日本語化して可読性を向上させました。

Changes

ドメイン層とダイアログテスト構造の統一化

Layer / File(s) Summary
RssiThreshold ドメイン層ユニットテスト
core/domain/src/test/java/kurou/androidpods/core/domain/RssiThresholdUseCaseTest.kt
RssiThresholdUseCaseTest を新規追加。MockK を用いて、RepositoryMock の observe() / update() への委譲動作を検証するテストクラスを実装しました。
Onboarding 権限・機能ダイアログテスト統合
feature/onboarding/src/test/java/kurou/androidpods/feature/onboarding/BluetoothDeniedDialogTest.kt, BluetoothUnavailableDialogTest.kt, PermissionDeniedDialogTest.kt
BluetoothDeniedDialog / BluetoothUnavailableDialog / PermissionDeniedDialog の各テストで、タイトル/メッセージ表示確認と Open Settings / Cancel ボタン操作による onConfirm / onDismiss コールバック検証を単一テスト内に統合。テスト名を日本語化しました。
Settings ダイアログテスト統合
feature/settings/src/test/java/kurou/androidpods/feature/settings/OverlayPositionDialogTest.kt, PermissionRequiredDialogTest.kt, RssiThresholdDialogTest.kt, ThemeModeDialogTest.kt
OverlayPositionDialog / PermissionRequiredDialog / RssiThresholdDialog / ThemeModeDialog の各テストで、ダイアログ表示・選択肢クリック・コールバック検証(onPositionSelected / onModeSelected / onThresholdSelected / onDismiss)を統合したテスト構造に再構成。assertTrue import も追加。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • ai-kurou/AndroidPods#102: RssiThresholdUseCase / RssiThresholdRepository / RssiThresholdDialog などの RSSI 閾値機能追加実装と直接対応するテスト追加・改編です。

Poem

🐰 テスト統一の春、ダイアログは新しい衣を
UI 確認と callback 検証、今は肩を並べて
日本語の名で目的が映り込み
レビュアー心も軽やか、品質の道を歩みゆく ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは「test: ダイアログテストとUseCaseテストの整備」で、変更内容を適切に要約している。複数のダイアログテストとUseCaseテストの整備という主要な変更を簡潔に表現している。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor-unit-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
feature/settings/src/test/java/kurou/androidpods/feature/settings/RssiThresholdDialogTest.kt (1)

17-17: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

画面方向の指定が必要です。

コーディングガイドラインに従い、@Config アノテーションに画面方向を指定する必要があります。ポートレート用に @Config(sdk = [35], qualifiers = "port") またはランドスケープ用に @Config(sdk = [35], qualifiers = "land") を使用してください。

💡 提案される修正
-@Config(sdk = [35])
+@Config(sdk = [35], qualifiers = "port")

コーディングガイドラインより:「Specify screen orientation with @Config(qualifiers = "port") for portrait or @Config(qualifiers = "land") for landscape.」

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/RssiThresholdDialogTest.kt`
at line 17, Update the `@Config` annotation on the RssiThresholdDialogTest (the
test class or annotated test function using `@Config`(sdk = [35])) to include a
screen orientation qualifier; e.g. change `@Config`(sdk = [35]) to `@Config`(sdk =
[35], qualifiers = "port") for portrait or qualifiers = "land" for landscape so
the test follows the coding guideline requiring explicit screen orientation.
feature/settings/src/test/java/kurou/androidpods/feature/settings/PermissionRequiredDialogTest.kt (1)

15-15: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

画面方向の指定が必要です。

コーディングガイドラインに従い、@Config アノテーションに画面方向を指定する必要があります。ポートレート用に @Config(sdk = [35], qualifiers = "port") またはランドスケープ用に @Config(sdk = [35], qualifiers = "land") を使用してください。

💡 提案される修正
-@Config(sdk = [35])
+@Config(sdk = [35], qualifiers = "port")

コーディングガイドラインより:「Specify screen orientation with @Config(qualifiers = "port") for portrait or @Config(qualifiers = "land") for landscape.」

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/PermissionRequiredDialogTest.kt`
at line 15, The `@Config` annotation in PermissionRequiredDialogTest (the
PermissionRequiredDialogTest class / test file) is missing a screen orientation
qualifier; update the `@Config`(sdk = [35]) usage to include qualifiers = "port"
for portrait or qualifiers = "land" for landscape (e.g., replace or augment the
existing `@Config` on PermissionRequiredDialogTest with `@Config`(sdk = [35],
qualifiers = "port") or `@Config`(sdk = [35], qualifiers = "land") as required by
the coding guideline).
feature/settings/src/test/java/kurou/androidpods/feature/settings/ThemeModeDialogTest.kt (1)

17-17: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

画面方向の指定が必要です。

コーディングガイドラインに従い、@Config アノテーションに画面方向を指定する必要があります。ポートレート用に @Config(sdk = [35], qualifiers = "port") またはランドスケープ用に @Config(sdk = [35], qualifiers = "land") を使用してください。

💡 提案される修正
-@Config(sdk = [35])
+@Config(sdk = [35], qualifiers = "port")

コーディングガイドラインより:「Specify screen orientation with @Config(qualifiers = "port") for portrait or @Config(qualifiers = "land") for landscape.」

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/ThemeModeDialogTest.kt`
at line 17, The test annotation `@Config`(sdk = [35]) on ThemeModeDialogTest must
include a screen orientation qualifier; update the `@Config` on the
ThemeModeDialogTest class or the specific test method to include qualifiers =
"port" (for portrait) or qualifiers = "land" (for landscape), e.g. replace
`@Config`(sdk = [35]) with `@Config`(sdk = [35], qualifiers = "port") or `@Config`(sdk
= [35], qualifiers = "land") so the test follows the coding guideline.
feature/settings/src/test/java/kurou/androidpods/feature/settings/OverlayPositionDialogTest.kt (1)

17-17: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

画面方向の指定が必要です。

コーディングガイドラインに従い、@Config アノテーションに画面方向を指定する必要があります。ポートレート用に @Config(sdk = [35], qualifiers = "port") またはランドスケープ用に @Config(sdk = [35], qualifiers = "land") を使用してください。

💡 提案される修正
-@Config(sdk = [35])
+@Config(sdk = [35], qualifiers = "port")

コーディングガイドラインより:「Specify screen orientation with @Config(qualifiers = "port") for portrait or @Config(qualifiers = "land") for landscape.」

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/OverlayPositionDialogTest.kt`
at line 17, The `@Config` annotation on OverlayPositionDialogTest (the line with
`@Config`(sdk = [35])) must include a screen orientation qualifier; update that
annotation to include qualifiers = "port" for portrait (or "land" for landscape)
so it reads `@Config`(sdk = [35], qualifiers = "port") (or "land") to comply with
the coding guideline.
🧹 Nitpick comments (1)
core/domain/src/test/java/kurou/androidpods/core/domain/RssiThresholdUseCaseTest.kt (1)

31-51: ⚡ Quick win

エラーケーステストの追加を検討してください

コーディングガイドラインでは「3-axis thinking: normal cases, error cases, and boundary values (approximately 1 test per axis)」を推奨しています。現在のテストは正常系のみをカバーしています。

RssiThresholdUseCase の実装が単純な委譲(例:fun observe() = repository.observe())であれば現状で十分ですが、何らかのロジックを含む場合は、以下のようなエラーケースの追加を検討してください:

  • repository.observe() が例外をスローする場合
  • repository.update() が失敗する場合

実装内容に応じて判断してください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/domain/src/test/java/kurou/androidpods/core/domain/RssiThresholdUseCaseTest.kt`
around lines 31 - 51, Add tests for error cases of RssiThresholdUseCase: write
one test where repository.observe() is stubbed to throw (e.g., every {
repository.observe() } throws SomeException) and assert that useCase.observe()
propagates or handles the exception as expected (use runTest and assertThrows or
collect the Flow error), and another test where repository.update(...) fails
(stub repository.update(RssiThreshold.NEAR) to throw or return a failed result)
and assert useCase.update(...) either throws or returns the expected failure; in
both tests use coVerify/verify to ensure repository.observe() or
repository.update(...) was called and confirmVerified(repository) to finish.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/OverlayPositionDialogTest.kt`:
- Line 17: The `@Config` annotation on OverlayPositionDialogTest (the line with
`@Config`(sdk = [35])) must include a screen orientation qualifier; update that
annotation to include qualifiers = "port" for portrait (or "land" for landscape)
so it reads `@Config`(sdk = [35], qualifiers = "port") (or "land") to comply with
the coding guideline.

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/PermissionRequiredDialogTest.kt`:
- Line 15: The `@Config` annotation in PermissionRequiredDialogTest (the
PermissionRequiredDialogTest class / test file) is missing a screen orientation
qualifier; update the `@Config`(sdk = [35]) usage to include qualifiers = "port"
for portrait or qualifiers = "land" for landscape (e.g., replace or augment the
existing `@Config` on PermissionRequiredDialogTest with `@Config`(sdk = [35],
qualifiers = "port") or `@Config`(sdk = [35], qualifiers = "land") as required by
the coding guideline).

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/RssiThresholdDialogTest.kt`:
- Line 17: Update the `@Config` annotation on the RssiThresholdDialogTest (the
test class or annotated test function using `@Config`(sdk = [35])) to include a
screen orientation qualifier; e.g. change `@Config`(sdk = [35]) to `@Config`(sdk =
[35], qualifiers = "port") for portrait or qualifiers = "land" for landscape so
the test follows the coding guideline requiring explicit screen orientation.

In
`@feature/settings/src/test/java/kurou/androidpods/feature/settings/ThemeModeDialogTest.kt`:
- Line 17: The test annotation `@Config`(sdk = [35]) on ThemeModeDialogTest must
include a screen orientation qualifier; update the `@Config` on the
ThemeModeDialogTest class or the specific test method to include qualifiers =
"port" (for portrait) or qualifiers = "land" (for landscape), e.g. replace
`@Config`(sdk = [35]) with `@Config`(sdk = [35], qualifiers = "port") or `@Config`(sdk
= [35], qualifiers = "land") so the test follows the coding guideline.

---

Nitpick comments:
In
`@core/domain/src/test/java/kurou/androidpods/core/domain/RssiThresholdUseCaseTest.kt`:
- Around line 31-51: Add tests for error cases of RssiThresholdUseCase: write
one test where repository.observe() is stubbed to throw (e.g., every {
repository.observe() } throws SomeException) and assert that useCase.observe()
propagates or handles the exception as expected (use runTest and assertThrows or
collect the Flow error), and another test where repository.update(...) fails
(stub repository.update(RssiThreshold.NEAR) to throw or return a failed result)
and assert useCase.update(...) either throws or returns the expected failure; in
both tests use coVerify/verify to ensure repository.observe() or
repository.update(...) was called and confirmVerified(repository) to finish.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0ab9f830-05a0-4bbb-bff5-0d8155bbe272

📥 Commits

Reviewing files that changed from the base of the PR and between a39596e and c9770fb.

📒 Files selected for processing (8)
  • core/domain/src/test/java/kurou/androidpods/core/domain/RssiThresholdUseCaseTest.kt
  • feature/onboarding/src/test/java/kurou/androidpods/feature/onboarding/BluetoothDeniedDialogTest.kt
  • feature/onboarding/src/test/java/kurou/androidpods/feature/onboarding/BluetoothUnavailableDialogTest.kt
  • feature/onboarding/src/test/java/kurou/androidpods/feature/onboarding/PermissionDeniedDialogTest.kt
  • feature/settings/src/test/java/kurou/androidpods/feature/settings/OverlayPositionDialogTest.kt
  • feature/settings/src/test/java/kurou/androidpods/feature/settings/PermissionRequiredDialogTest.kt
  • feature/settings/src/test/java/kurou/androidpods/feature/settings/RssiThresholdDialogTest.kt
  • feature/settings/src/test/java/kurou/androidpods/feature/settings/ThemeModeDialogTest.kt

@sonarqubecloud
Copy link
Copy Markdown

@ai-kurou ai-kurou merged commit 22efd17 into main May 29, 2026
12 checks passed
@ai-kurou ai-kurou deleted the feature/refactor-unit-test branch May 29, 2026 08:55
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