The Accessibility initializer is not properly initializing the open case when for the version of swift-syntax used by the project. This was resulting in open class mocks being generated with the default (internal) access level.
Bug
With the library's current behavior, this code:
open class MyOpenClass {
open func myFunc() { }
}
would generate this mock (simplified for readability):
class MockMyOpenClass {
override func myFunc() { ... }
}
Fix
Match .keyword(.open) instead of .identifier("open") for the open access level.
With this change, the hypothetical class would be generated as:
public class MockMyOpenClass {
public override func myFunc() { ... }
}
Tests
To create access level separation between mocks and test code, I've created CuckooMocks frameworks for each platform, each depended upon by each corresponding test target. The only change to existing tests is that this framework must be imported. More importantly, this separation allows for tests to prove that access levels of mocks are properly generated.
I'm open to feedback from the maintainer if they have differences in preference in this project structuring. If there were a way to determine access level from another method (e.g. reflection), I would opt for that, but it seems that this is really the only way with Swift to prove internal vs. public access levels for generated mocks.
I've squashed the commits and merged it. Thank you so much for this PR, mainly for the separation of mocks into its own PR, it will help with accessibility testing.
Description
The
Accessibility
initializer is not properly initializing theopen
case when for the version of swift-syntax used by the project. This was resulting in open class mocks being generated with the default (internal) access level.Bug
With the library's current behavior, this code:
would generate this mock (simplified for readability):
Fix
Match
.keyword(.open)
instead of.identifier("open")
for theopen
access level.With this change, the hypothetical class would be generated as:
Tests
To create access level separation between mocks and test code, I've created
CuckooMocks
frameworks for each platform, each depended upon by each corresponding test target. The only change to existing tests is that this framework must be imported. More importantly, this separation allows for tests to prove that access levels of mocks are properly generated.I'm open to feedback from the maintainer if they have differences in preference in this project structuring. If there were a way to determine access level from another method (e.g. reflection), I would opt for that, but it seems that this is really the only way with Swift to prove
internal
vs.public
access levels for generated mocks.