Comments (5)
from cedar.
Thanks for your message!
I looked further and see that the exception for the test example I referenced is in the beforeEach block for the test. The exception occurs when the bold line below is executed:
describe(@"#drawRect2:", ^{
__block UIBezierPath *fakePath;
__block CGRect passedRect;
__block Swizzlean *bezierSwizz;
__block struct CGPath *path;
beforeEach(^{
fakePath = nice_fake_for([UIBezierPath class]);
bezierSwizz = [[Swizzlean alloc] initWithClassToSwizzle:[UIBezierPath class]];
[bezierSwizz swizzleClassMethod:@selector(bezierPathWithRect:) withReplacementImplementation:^(id self, CGRect rect) {
passedRect = rect;
return [fakePath retain];
}];
path = CGPathCreateMutable();
fakePath stub_method(@selector(CGPath)).and_return(path);
view.bounds = CGRectMake(0,0,200,200);
[view drawRect:CGRectZero];
});
afterEach(^{
[bezierSwizz resetSwizzledClassMethod];
});
fit(@"sets the shadow color", ^{
view.layer.shadowColor should equal([UIColor blackColor].CGColor);
});
});
If I add a const specifier to the declaration for path, the exception goes away.
__block const struct CGPath *path;
Thanks again for your help!
from cedar.
The invalid return type
message sounds really similar to the error messages for Cedar's fakes.
My guess is that you have a fake that returns a CGPath *
but the UIKit api now returns a const CGPath *
.
What's happening under the hood is that Cedar's fakes try to verify that your stubbed values are correct - it wants to catch errors about mismatched return types early, so that you aren't surprised when your tests are wrong. Perhaps as part of building up your subview, or the label, there's a fake somewhere that's providing a CGPath?
That's all just my intuition, but if I'm wrong, I'd try tracking down the "invalid return value type" message, set the appropriate breakpoint in Cedar and try to walk back up the call stack and understand how that happened.
from cedar.
Oh sorry @markcarl I didn't see your response, I'm glad you got it to work again. Just a few thoughts and kind words of advice:
- Don't make fakes for UIBezierPath -- you don't own that API and apple can change it. Those tests will be brittle and break again in the future.
- In general, try not to make fakes for value types like bezier paths, arrays or dictionaries
Only mentioning that because I've been bit by that a dozen times before personally, and it's always a tough issue to troubleshoot.
from cedar.
Closing now as resolved, but feel free to re-open if you'd like to discuss it more. Always happy to talk to Cedar users :)
from cedar.
Related Issues (20)
- Console output is logged out of order HOT 1
- new project can't find cedar HOT 1
- Xcode 7.3 beta 5 errors on __weak in manual reference counting HOT 6
- Use of @import HOT 2
- Custom matchers fails to compile using Xcode 7.3 HOT 4
- Test observation issues HOT 2
- Weak References in XCode 7.3 HOT 4
- Playground support
- Installing template fails on AppCode 2016.1 HOT 1
- Cedar silently accepts misuse of the test structure DSL
- Running Individual Specs HOT 9
- Cedar, Swift and Protocol Declarations - Compiler error HOT 7
- testing watchOS with Cedar and Swift
- Cedar Standalone with XCode 8/ios-sim 5.0.8 HOT 4
- Cedar needs a sticker. HOT 4
- Cedar status HOT 1
- Xcode 9 compatibility HOT 8
- [Known Issue] Cedar's test specs cannot be folded in Xcode 9
- spy_on NSDate crashes on Xcode 10 HOT 5
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 cedar.