Skip to content

[TESTING] Fix Swift Package Dependencies for Tests #122

@DrunkOnJava

Description

@DrunkOnJava

📋 Sub-task of Epic #102

Problem

Test targets cannot find module dependencies, preventing any tests from compiling.

Error Messages

error: cannot find 'XCTest' in scope
error: cannot find type 'XCTestCase' in scope  
error: no such module 'SnapshotTesting'

Root Causes

  1. Test targets not properly linked to SPM modules
  2. Missing test dependencies in Package.swift files
  3. Incorrect import paths
  4. XCTest framework not linked

Required Fixes

1. Update Module Package.swift Files

// Each module's Package.swift needs:
.testTarget(
    name: "CoreTests",
    dependencies: [
        "Core",
        .product(name: "SnapshotTesting", package: "swift-snapshot-testing")
    ],
    path: "Tests"
)

2. Fix Test Target Configuration

  • Ensure test targets have proper framework search paths
  • Link XCTest framework explicitly
  • Set up proper module maps

3. Test File Structure

Modules/Core/
├── Package.swift
├── Sources/
└── Tests/
    └── CoreTests/
        ├── ItemTests.swift
        └── Resources/

Acceptance Criteria

  • All test targets compile without errors
  • XCTest properly imported in all test files
  • SnapshotTesting available where needed
  • Module dependencies resolved
  • Tests can access public APIs from modules
  • Xcode test navigator shows all tests

Verification Steps

  1. Clean build folder
  2. Run swift package resolve
  3. Build test targets: swift build --build-tests
  4. Run tests: swift test

Metadata

Metadata

Labels

P0Production blocker - must fix immediatelybugSomething isn't workingsub-taskPart of a larger epictestingTesting related changes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions