Git Product home page Git Product logo

Comments (3)

Przemyslaw-Wosko avatar Przemyslaw-Wosko commented on May 27, 2024

Hi @nagarro-vijaykumar04,
Thanks for raising an issue!
So basically we have

protocol A {
 func protocolAMethod()
}

then we have

protocol B {
 func protocolBMethod()
}

and we want to have mock that conforms to both protocols.

Have you tried with typealias?

typealias ProtocolAB = A & B 

or new protocol instead?

protocol ProtocolAB: A, B  {} 
  • i didn't tried it out*

i will play with this case latter and let you know

from swiftymocky.

nagarro-vijaykumar04-zz avatar nagarro-vijaykumar04-zz commented on May 27, 2024

Hi,
Thanks for your swiftly reply!

The scenario mentioned above is same as your last point i.e.:
protocol ProtocolAB: A, B {}

As protocol ProtocolAB doesn't have the methods of protocols A & B as its own definition, while creating mocks for it compiler says, ProtocolABMock doesn't confirm with protocol A & protocol B

from swiftymocky.

amichnia avatar amichnia commented on May 27, 2024

@nagarro-vijaykumar04

Hi, I just verified and inheritance seems to work. Added new test to SwiftyMocky, to verify inheritance case for version 1.02 +.

Our test looks like that:

//sourcery: AutoMockable
protocol SimpleProtocolWithMethods {
    func simpleMethod()
    func simpleMehtodThatReturns() -> Int
    func simpleMehtodThatReturns(param: String) -> String
    func simpleMehtodThatReturns(optionalParam: String?) -> String?
}

//sourcery: AutoMockable
protocol SimpleProtocolWithProperties {
    var property: String { get set }
    weak var weakProperty: AnyObject! { get set }
    var propertyGetOnly: String { get }
    var propertyOptional: Int? { get set }
    var propertyImplicit: Int! { get set }
}

//sourcery: AutoMockable
protocol SimpleProtocolThatInheritsOtherProtocols: SimpleProtocolWithMethods, SimpleProtocolWithProperties {
}

Generated mock SimpleProtocolThatInheritsOtherProtocolsMock adopts both protocols, and seems to be working fine.

It seems that your problem is not related to protocol inheritance. Anyway - if you could, please provide actual A,B and ProtocolAB code that is breaking generation for you, then I will be able to reopen it and fix the issue. You can reach me on SwiftyMocky slack, if you don't want to post your code here

I'm closing it for now.

from swiftymocky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.