Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Prefix mock- and stubnames

Open emielv opened this issue 6 years ago • 2 comments

Hi all,

My team wants to slowly integrate the Cuckoo framework into our project for generating mocks. We want to support tests that still use our own mocks and new / refactored tests that use Cuckoo mocks. The problem we are facing is that there are conflicts between mocks we wrote ourselves and mocks that Cuckoo generates e.g. same classname for the mocks and it also reduces readability because it’s not immediately obvious if you are working with Cuckoo mocks or not. Is it possible / is there a way to add a prefix to the classnames of the generated mocks e.g. generating a mock for protocol Abc will generate CuckooMockAbc / CKMockAbc?

Thanks in advance!

emielv avatar Dec 05 '19 13:12 emielv

Hey, that's not a bad idea. I'd welcome a PR that would implement this to make one's life easier.

You need to start by running make dev in project root, which creates generator project file for the Cuckoo workspace.

I think you'd have to edit GenerateMocksCommand.swift and define a command named "mock-prefix" perhaps that would register the prefix given by user, optional all the way to the mocks generation and then either using that or the default "Mock".

Let me know if you get stuck or need some clarification, I'll be happy to help.

MatyasKriz avatar Dec 11 '19 11:12 MatyasKriz

Hello @MatyasKriz , I created a PR regarding this feature and would love some feedback.

Thanks!

emielv avatar Dec 15 '19 19:12 emielv