typealiased / mockingbird

A Swifty mocking framework for Swift and Objective-C.

Home Page:https://mockingbirdswift.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generator don't generate mocks for Moya.PluginType protocol

ars-java opened this issue · comments

commented

New Issue Checklist

Overview

  • SPM library
  • Moya as dependency of main target
  • main target as dependency of test target

I use mock(..) in test target to generate Moya.PluginType protocol mock but generator don't generate mock method. Other mocks was generated successfully.

I tried create my own protocol and mock was generated successfully.

Example

Script to generate:

#!/bin/bash
set -eu
cd "$(dirname "$0")"
swift package describe --type json > project.json
.build/checkouts/mockingbird/mockingbird generate --project project.json \
  --output-dir Tests/ProjTests/GeneratedMocks \
  --testbundle ProjTests \
  --targets ProjTests Proj \
// swift-tools-version: 5.6
import PackageDescription

let package = Package(
    name: "Proj",
    platforms: [
        .iOS(.v14),
    ],
    products: [
        .library(
            name: "Proj",
            targets: ["Proj"]),
    ],
    dependencies: [
        .package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "15.0.0")),
        .package(url: "https://github.com/birdrides/mockingbird", .upToNextMajor(from: "0.9.0")),
    ],
    targets: [
        .target(
            name: "Proj",
            dependencies: [
                "Moya",
                .product(name: "CombineMoya", package: "Moya"),
                .product(name: "Mockingbird", package: "mockingbird"),
            ]),
        .testTarget(
            name: "ProjTests",
            dependencies: [
                "Proj",
                "Moya",
                .product(name: "Mockingbird", package: "mockingbird"),
            ],
        ),
    ]
)
import Moya
...
final class MyTest: XCTestCase {
    func testExample() throws {
        let f = mock(PluginType.self) // 'mock' is unavailable: No generated mock for this type; try building the test target (⇧⌘U) to generate mocks
    }
}

Expected Behavior

Mock was generated.

Environment

  • Mockingbird CLI version 0.20.0
  • swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
    Target: x86_64-apple-macosx12.0
  • SPM package
  • XCTest, Quick/Nimble
commented

Is it the case of Mocking External Type and I can't mock this type now?

@ars-java Why did you even close your issue without having an answer for it?