Comments (10)
Hi, thank you for the kind words, we are glad you like it :)
Anyway, @FilipDolnik came to me with the idea before, but I dismissed it that it is not a good practise to make source
know about its tests. However, if you are interested in this feature, we will add it.
from cuckoo.
Yeah, I think that would be awesome.
Consider for example a VIP app architecture. In the ideal situation, classes only have explicit dependencies, defined as protocols. In order to test the class you'll only need mocks for protocols, and not for the classes:
// arrange
let dependencyMock = DependencyProtocolMock()
dependencyMock.getDataHandler = { return someData }
let delegateMock = DelegateProtocolMock()
let testInstance = TestClass(dependency: dependency)
testInstance.delegate = delegateMock
// act
testInstance.doSomething()
// assert
XCTAssertEqual(delegateMock.delegateMethodCallCount, 1)
So you'll want to only generate mocks for selected protocols.
And you'll never need to mock TestClass.
Does this make sense?
from cuckoo.
I am also very thrilled with the work on this library and hope to see it continue to evolve. That said, I'm not sure the value of this feature since mocks are already only generated for files added to build script. This feels bad since it brings awareness of Cuckoo into the code-base when it would be better left as a build step.
@impopappfactory, what capabilities are you lacking today that this addresses? Doesn't the explicit file list work for you? I could see improvements on filters happening there though (i.e. regexes etc. for include strategies).
@TadeasKriz, keep up the good work!
from cuckoo.
@pusolito I would normally have Cuckoo run through all project files (or maybe split that in logical groups/modules e.g. NetworkProtocolMocks/MainMocks/SomeFeatureMocks but still process all files in a given module). And I definitely can't see use case for the generated class mocks.
And I really don't see any drawbacks of bringing awareness of tests into the code, if that only adds attributes to entities we explicitly want to mock. If software is designed such as it uses protocols as boundaries between components, it's assumed these protocol will be mocked in order to test actual implementation.
from cuckoo.
@impopappfactory Would --no-mock-classes
setting that would ignore all classes when generating mocks work for your scenario? It is always better if the sources don't know about how they are tested. I suppose we could also add support for whitelisting/blacklisting type name patterns, what do you think?
from cuckoo.
@TadeasKriz Yeah, that would solve given use case. Thanks!)
from cuckoo.
@impopappfactory Please give 43cf00b208a37a9f460ac2d39ea7dbc4c483df7e
commit a spin ;)
from cuckoo.
Yeah, looks great, thanks @FilipDolnik! ) I'm currently looking into converting Generator to use templates engine, to make it extensible. I've also got some ideas on how to add support for hierarchies and generics.
from cuckoo.
@impopappfactory Sounds awesome! :) Make sure you work with Generator in this repository and not the old one (which has its own repository).
from cuckoo.
Figured that out, thanks!
from cuckoo.
Related Issues (20)
- Use Cuckoo in product target? HOT 2
- Add support for Protocols requiring AnyActor conformance HOT 4
- Permission denied: Can't add comments to the list of files HOT 4
- Strip conflicting imports HOT 2
- Compilation fails in Xcode 14.3
- Error when running Cuckoo/run (cuckoo_generator ver. 1.10.2) HOT 4
- Unable to build with SPM install (ld: symbol(s) not found for architecture arm64) HOT 8
- Cuckoo need XCTest.framework in link binary with Libraries section. otherwise it shows error that is "cannot find 'XCTFail' in scope" in MockManager.swift file HOT 1
- Throwing "'some' types are only permitted in properties, subscripts, and functions" when `func` throws & has `some` for its parameter HOT 2
- Compiler custom flags are not supported by Cuckoo generator HOT 2
- Cuckoo does not support block-type closure HOT 2
- Carthage/Checkouts/Cuckoo/Generator/Generator.xcodeproj' does not exist. HOT 9
- Plenty errors in GeneratedMocks.ts for swift 5.8.1 HOT 2
- Error: Expected member name or constructor call after type name HOT 28
- Issue with Cuckoo Generating Mock for a variable's property HOT 1
- Mock restricts subclasses for method argument HOT 4
- Issue with variable name as `extension` HOT 1
- Problem with run script on Xcode 15 HOT 6
- Not able to initialise Mock Object HOT 1
- More descriptive failure messages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuckoo.