Skip to content

feat: add configurable mockPrefix to Cuckoofile.toml#598

Open
mmustafasenoglu wants to merge 1 commit into
Brightify:masterfrom
mmustafasenoglu:feat/configurable-mock-prefix
Open

feat: add configurable mockPrefix to Cuckoofile.toml#598
mmustafasenoglu wants to merge 1 commit into
Brightify:masterfrom
mmustafasenoglu:feat/configurable-mock-prefix

Conversation

@mmustafasenoglu

Copy link
Copy Markdown

Summary

Add a global mockPrefix option to Cuckoofile.toml that allows customizing the prefix of generated mock class names.

Closes #564

Changes

  • Module.swift: Added mockPrefix to DTO.Options and Options structs
  • HasName.swift: Changed mockName to use Module.mockPrefix instead of hardcoded "Mock"
  • GenerateCommand.swift: Added parsing for global mockPrefix TOML key
  • Cuckoofile.toml: Added documented mockPrefix option

Usage

# Global prefix (default: "Mock")
mockPrefix = "Fake"

[modules.MyProject]
output = "GeneratedMocks.swift"

This generates FakeGreeter instead of MockGreeter.

Backward Compatibility

  • Default value is "Mock", preserving existing behavior
  • No changes to generated output when mockPrefix is not specified

Add a global `mockPrefix` option to Cuckoofile.toml that allows
customizing the prefix of generated mock class names.

Default: "Mock" (existing behavior)
Example: mockPrefix = "Fake" generates FakeGreeter instead of MockGreeter

The prefix can be set:
- Globally in Cuckoofile.toml: `mockPrefix = "Fake"`
- Per-module in options: `[modules.X.options]` with `mockPrefix = "Fake"`

Closes Brightify#564
@mmustafasenoglu

Copy link
Copy Markdown
Author

Hi @MatyasKriz, thanks for taking a look!

That's great to hear you had planned this for 2.0. I've implemented the mockPrefix config option in Cuckoofile.toml that lets users customize the prefix (defaults to "Mock").

I've also added a basic test case for the prefix configuration. Happy to adjust the implementation if you'd prefer a different approach. Let me know how you'd like to proceed with testing on your end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customize generated mock prefix

1 participant