Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Issue with Cuckoo Generating Mock for a variable's property

Open sofiafarina-95 opened this issue 2 years ago • 1 comments

Description I'm encountering an issue when using Cuckoo to generate mocks for a property named currentCastedMedia within a protocol. The property is declared with the BehaviorRelay type, and it holds a tuple with several optional and non-optional elements.

Here's how the property is defined in the protocol: var currentCastedMedia: BehaviorRelay<(streamURL: URL?, title: String, albumName: String, thumbnailURL: URL?, playAtTime: TimeInterval, mediaType: CastMediaType)?> { get }

And here's how it's implemented in the class conforming to the protocol: var currentCastedMedia = BehaviorRelay<(streamURL: URL?, title: String, albumName: String, thumbnailURL: URL?, playAtTime: TimeInterval, mediaType: CastMediaType)?>(value: nil)

However, when Cuckoo generates mocks for this property, the generated code seems incomplete and not matching the property's declaration.

Here's a snippet of the generated code:

Screenshot 2023-11-02 at 9 52 16 PM Screenshot 2023-11-02 at 9 52 35 PM Screenshot 2023-11-02 at 9 52 52 PM Screenshot 2023-11-02 at 9 53 04 PM

The generated code appears to be incomplete and not in alignment with the property's declaration in the protocol and class.

I've verified that the protocol and class implementation are correct, and the issue seems to be related to how Cuckoo handles this specific property.

Steps Taken:

  1. Verified the correctness of the protocol and class declarations.
  2. Manually added the incomplete property and cleared the Generate Cuckoo Mock in Build Phases so it won't change back the manually added fixes.

Expectation: I expect Cuckoo to generate mocks for the currentCastedMedia property in a way that accurately reflects the property's declaration in the protocol and class.

Any guidance or insights into this issue would be greatly appreciated.

sofiafarina-95 avatar Nov 02 '23 13:11 sofiafarina-95

Hey, seems like there's a bug in parsing the type, but to be frank, you should define a struct to use instead of a tuple with so many parameters. It should work fine when changed to BehaviorRelay<SongInfo?> should pass fine.

I'm pretty sure that your specific use-case is fixed in the version I'm working on, but it's not releasable yet.

MatyasKriz avatar Nov 02 '23 21:11 MatyasKriz