Skip to content

test: 식단 기능 테스트 코드 작성 - #523

Open
oeunji wants to merge 11 commits into
developfrom
test/dining
Open

test: 식단 기능 테스트 코드 작성#523
oeunji wants to merge 11 commits into
developfrom
test/dining

Conversation

@oeunji

@oeunji oeunji commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

#️⃣연관된 이슈

📝작업 내용

식단 기능에 테스트 코드를 추가했습니다. 작성 완료한 테스트 케이스는 노션에 표시했습니다.
테스트 케이스는 수기로 작성 후 테스트 코드 작성은 Claude Code에게 맡겨봤습니다.

💬리뷰 요구사항(선택)

키보드의 command+u를 누르면 테스트 코드를 빌드할 수 있습니다! 테스트 코드는 koin-stage에서만 실행합니다.

테스트 코드를 작성하면서 로깅도 함께 테스트 코드를 작성하려고 했으나, inputSubject 등의 로직이 ViewController에서 Private으로 선언되어 있어 테스트가 불가했는데요, 이는 다음 작업으로 로깅도 테스트할 수 있게 구조를 리팩토링 해보려 합니다!

관련 내용을 블로그에 작성해봤습니다! 작업 내용에 대한 이해가 필요하다면 블로그 글 읽어주시면 좋을 것 같아요~ 구독도 해주시면 감사해유 😋

나훈 님이 Issue에 따봉 남겨주셨길래 Reviewers로 등록 해보겠습니다 ㅎㅅㅎ

@oeunji
oeunji requested a review from hgjwilly August 8, 2026 08:34
@oeunji oeunji self-assigned this Aug 8, 2026
@oeunji oeunji added the TEST 테스트 코드 작성 label Aug 8, 2026
@oeunji oeunji linked an issue Aug 8, 2026 that may be closed by this pull request
5 tasks
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR replaces the legacy unit and UI test targets with koinUnitTests. It adds dining fixtures, a repository spy, Combine test support, and tests for date handling, dining-list fetching, and menu sharing. Shared schemes now run the new unit-test bundle.

Changes

Dining unit-test target

Layer / File(s) Summary
Unit-test target and scheme wiring
koin.xcodeproj/project.pbxproj, koin.xcodeproj/xcshareddata/xcschemes/*, koinUITests/*
The project replaces koinTests and koinUITests with koinUnitTests, registers its sources and product, configures test hosting, and enables the bundle in shared schemes. Duplicate resource entries and obsolete UI tests are removed.
Dining test support
koinUnitTests/Support/*, koinUnitTests/Doubles/*
Fixtures create dining DTOs, items, and dates. SpyDiningRepository records requests and share models. Publisher.firstValue() supports asynchronous Combine tests.
Dining behavior coverage
koinUnitTests/Dining/*
Tests cover meal-time boundaries, dining-list filtering and ordering, date forwarding, share-model conversion, date formatting, and repository forwarding.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

  • BCSDLab/KOIN_iOS#462 — The tests cover dining use cases and repository behavior introduced or modified by this PR.
  • BCSDLab/KOIN_iOS#521 — The tests cover the dining use cases and date provider introduced or reorganized by this PR.

Suggested reviewers: hgjwilly

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.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
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.
Title check ✅ Passed The title clearly describes the addition of unit tests for the dining feature, which is the main change in the pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/dining

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.

@oeunji
oeunji requested a review from KimNahun August 8, 2026 08:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@koin.xcodeproj/xcshareddata/xcschemes/koin.xcscheme`:
- Around line 34-40: Update the koin scheme’s TestAction configuration so
koinUnitTests runs against the Debug configuration rather than Release,
preserving testability for its `@testable` import. Alternatively, enable
ENABLE_TESTABILITY only for the koin Release build path used by these tests.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c4f0021c-5942-4dfe-9415-b3a6419b1718

📥 Commits

Reviewing files that changed from the base of the PR and between 585dda5 and 4643366.

📒 Files selected for processing (12)
  • koin.xcodeproj/project.pbxproj
  • koin.xcodeproj/xcshareddata/xcschemes/NotificationService.xcscheme
  • koin.xcodeproj/xcshareddata/xcschemes/koin-stage.xcscheme
  • koin.xcodeproj/xcshareddata/xcschemes/koin.xcscheme
  • koinUITests/koinUITests.swift
  • koinUITests/koinUITestsLaunchTests.swift
  • koinUnitTests/Dining/DateProviderTests.swift
  • koinUnitTests/Dining/FetchDiningListUseCaseTests.swift
  • koinUnitTests/Dining/ShareMenuListUseCaseTests.swift
  • koinUnitTests/Doubles/SpyDiningRepository.swift
  • koinUnitTests/Support/DiningFixtures.swift
  • koinUnitTests/Support/PublisherTestSupport.swift
💤 Files with no reviewable changes (2)
  • koinUITests/koinUITestsLaunchTests.swift
  • koinUITests/koinUITests.swift

Comment on lines +34 to +40
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A001E2C32845091F00D6C310"
BuildableName = "koinTests.xctest"
BlueprintName = "koinTests"
ReferencedContainer = "container:koin.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A001E2CD2845091F00D6C310"
BuildableName = "koinUITests.xctest"
BlueprintName = "koinUITests"
BlueprintIdentifier = "EC692284302700A400EE26ED"
BuildableName = "koinUnitTests.xctest"
BlueprintName = "koinUnitTests"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify whether the new test target requires an `@testable` import.
rg -n -C 2 '`@testable`[[:space:]]+import[[:space:]]+koin' koinUnitTests

# Compare the application Debug and Release testability settings.
sed -n '6747,6990p' koin.xcodeproj/project.pbxproj

Repository: BCSDLab/KOIN_iOS

Length of output: 11811


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

proj = Path("koin.xcodeproj/project.pbxproj").read_text()

configs = re.findall(r'(EC69228B302700A400EE26ED|EC69228C302700A400EE26ED|\w{24})\s*/\*\s*(Debug|Release)\s*\*/\s*=\s*\{\s*isa\s*=\s*XCBuildConfiguration;.*?name\s*=\s*(?:Debug|Release);\s*\};', proj, re.S)
for uuid, name in configs:
    content = re.search(fr'{re.escape(uuid)}\s*/\*\s*{name}\s*\*/\s*=.*?name\s*=\s*{name};\s*\};', proj, re.S).group(0)
    print(f"{uuid} {name} ENABLE_TESTABILITY=", "ENABLE_TESTABILITY = YES" in content)

test_schemes = []
for p in Path("koin.xcodeproj/xcshareddata/xcschemes").glob("*.xcscheme"):
    scheme = p.read_text()
    if "EC692284302700A400EE26ED" in scheme:
        m = re.search(r'<TestAction[^>]*buildConfiguration="([^"]+)"', scheme)
        test_schemes.append((p, m.group(1) if m else None, "`@testable` import koin" in scheme))

print("Test schemes:", test_schemes)

all_imports = []
for path in sorted(Path("koinUnitTests").rglob("*.swift")):
    all_imports.extend(path.read_text(errors="ignore").splitlines())
print("Files using `@testable` import koin:", sum(1 for line in all_imports if "`@testable` import koin" in line))
print("All references:", [f"{p}:{line_no}" for p in all_imports[:0]])
PY

Repository: BCSDLab/KOIN_iOS

Length of output: 447


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

proj = Path("koin.xcodeproj/project.pbxproj").read_text()

uuids = [
    "EC69228B302700A400EE26ED",
    "EC69228C302700A400EE26ED",
]
for uuid in uuids:
    m = re.search(rf'({re.escape(uuid)})\s*/\*\s*(Debug|Release)\s*\*/', proj)
    if not m:
        continue
    uuid, name = m.groups()
    full = re.search(rf'{re.escape(uuid)}\s*/\*\s*{re.escape(name)}\s*\*/\s*=.*?name\s*=\s*{re.escape(name)};\s*\};', proj, re.S).group(0)
    print(f"{uuid} {name} ENABLE_TESTABILITY=", "ENABLE_TESTABILITY = YES" in full)

test_schemes = []
schemes_dir = Path("koin.xcodeproj/xcshareddata/xcschemes")
if schemes_dir.exists():
    for p in sorted(schemes_dir.glob("*.xcscheme")):
        scheme = p.read_text()
        if "EC692284302700A400EE26ED" in scheme:
            mt = re.search(r'<TestAction[^>]*buildConfiguration="([^"]+)"', scheme)
            mi = re.search(r'`@testable`\s+import\s+koin', scheme)
            test_schemes.append((str(p), mt.group(1) if mt else None, bool(mi)))
print("Test schemes:", test_schemes)

all_imports = []
for path in sorted(Path("koinUnitTests").rglob("*.swift")):
    all_imports.extend(path.read_text(errors="ignore").splitlines())
print("Files using `@testable` import koin:", sum(1 for line in all_imports if "`@testable` import koin" in line))
PY

python3 - <<'PY'
from pathlib import Path

files = {}
for path in sorted(Path("koinUnitTests").rglob("*.swift")):
    text = path.read_text(errors="ignore").splitlines()
    hits = [(i+1, line.strip()) for i, line in enumerate(text) if "`@testable` import koin" in line]
    if hits:
        files[str(path)] = hits

print("koinUnitTests files with `@testable` import koin:")
for path, hits in files.items():
    print(path)
    for i, line in hits[:5]:
        print(f"  {i}: {line}")
    if len(hits) > 5:
        print(f"  ... and {len(hits)-5} more")
PY

Repository: BCSDLab/KOIN_iOS

Length of output: 486


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

proj = Path("koin.xcodeproj/project.pbxproj").read_text()

uuid_config_map = {
    "EC69228B302700A400EE26ED": "Debug",
    "EC69228C302700A400EE26ED": "Release",
}

for uuid, name in uuid_config_map.items():
    escaped_uuid = re.escape(uuid)
    escaped_name = re.escape(name)
    m = re.search(rf'{escaped_uuid}\s*/\*\s*{escaped_name}\s*\*/', proj)
    if not m:
        continue
    full = re.search(rf'{escaped_uuid}\s*/\*\s*{escaped_name}\s*\*/\s*=.*?name\s*=\s*{escaped_name};\s*\};', proj, re.S).group(0)
    has_setting = "ENABLE_TESTABILITY = YES" in full
    print(f"{uuid} {name} ENABLE_TESTABILITY= {has_setting}")

test_schemes = []
schemes_dir = Path("koin.xcodeproj/xcshareddata/xcschemes")
if schemes_dir.exists():
    for p in sorted(schemes_dir.glob("*.xcscheme")):
        scheme = p.read_text()
        if "EC692284302700A400EE26ED" in scheme:
            mt = re.search(r'<TestAction[^>]*buildConfiguration="([^"]+)"', scheme)
            mi = re.search(r'`@testable`\s+import\s+koin', scheme)
            test_schemes.append((str(p), mt.group(1) if mt else None, bool(mi)))
print("Test schemes:", test_schemes)

files = {}
for path in sorted(Path("koinUnitTests").rglob("*.swift")):
    text = path.read_text(errors="ignore").splitlines()
    hits = [(i+1, line.strip()) for i, line in enumerate(text) if "`@testable` import koin" in line]
    if hits:
        files[str(path)] = hits

print("koinUnitTests files with `@testable` import koin:", len(files))
for path, hits in list(files.items())[:5]:
    print(path)
    for i, line in hits[:5]:
        print(f"  {i}: {line}")
PY

Repository: BCSDLab/KOIN_iOS

Length of output: 468


Don’t run @testable tests from a Release scheme.

koinUnitTests uses @testable import koin, but the koin Release configuration does not enable testability. Use Debug for TestAction, or enable ENABLE_TESTABILITY = YES for koin only in the Release build path used by tests.

🤖 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 `@koin.xcodeproj/xcshareddata/xcschemes/koin.xcscheme` around lines 34 - 40,
Update the koin scheme’s TestAction configuration so koinUnitTests runs against
the Debug configuration rather than Release, preserving testability for its
`@testable` import. Alternatively, enable ENABLE_TESTABILITY only for the koin
Release build path used by these tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TEST 테스트 코드 작성

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: 식단 기능 테스트 코드 작성

1 participant