티스토리 뷰
[It's not But!! update 2013.08.09] KIWI (BDD/TDD Framework) seems like to have a bug
gunnih 2013. 5. 23. 23:41As you already know that, to develop an application we need to use always some test framework.
Actually following two keywords are very common.
- BDD (Behavior Driven Development)
- TDD (Test Driven Development)
In a project, I am using Kiwi framework to do unit test.
Today I found a weird behavior from Kiwi.
Let's see this code.
#import "Kiwi.h"
#import "KWSpec+WaitFor.h"
@interface MyInterface : NSObject
-(NSString *)speak:(NSString *)str;
@end
@implementation MyInterface
-(NSString *)speak:(NSString *)str {
return [NSString stringWithFormat:@"I'm speaking %@", str];
}
@end
SPEC_BEGIN(MyKiwiTest)
__block MyInterface *myObj;
beforeAll(^{
myObj = [[MyInterface alloc] init];
});
describe(@"My Kiwi Test", ^{
context(@"Selector Test", ^{
it(@"Log String", ^{
[[myObj should] receive:@selector(speak:)];
NSLog(@"%@", [myObj speak:@"to YOU!!"]);
});
});
});
SPEC_END
With this code you will get this log message :
2013-05-22 22:45:11.179 MyKiwiTest[70475:c07] (null)
What's wrong with it? I just set the expectation, and then this selector was not called....;(
It seems like to have a bug.
But, let's change the position of expectation like this
context(@"Selector Test", ^{
[[myObj should] receive:@selector(speak:)];
it(@"Log String", ^{
NSLog(@"%@", [myObj speak:@"to YOU!!"]);
});
});
Finally you get this log message :
2013-05-22 22:46:23.981 MyKiwiTest[77556:c07] I'm speaking to YOU!!
I couldn't find the right reason, but there is a key to find the reason.
in KWExample interface has this selector :
- (void)visitItNode:(KWItNode *)aNode;
And I think, the running cycle of this selector causes this problem.
Anyhow you can face some problem with Unit test because of this situation.
And this way is just a kind of tipp to perform the selector.
Therefore, please be careful to write test codes.
thx
2013-08-09 update
!!! It was not a Bug !!!
If you prevent this kind of error, just call 'andReturn:@YES' .
ex :
[[myObj should] receive:@selector(speak:) andReturn:@YES];
Then you will not face this problem anymore!! :D
Thanks :)
'programming' 카테고리의 다른 글
CocoaPods Error with XCode6 (0) | 2014.11.05 |
---|---|
Git Log : print merge tree (0) | 2013.11.10 |
iOS Development : ivar and property declaration and binding (iOS 개발 ivar와 property 선언 그리고 binding) (0) | 2012.01.21 |
Apple은 알고 있지만, 나는 모르는 점. (1) | 2009.12.08 |
Windows Mobile Today Plugin 만들기. (0) | 2009.08.10 |
- Total
- Today
- Yesterday
- 세부
- ios
- Blue Card
- IFA 2011
- windows mobile
- 필리핀
- IFA
- mobile
- 교육
- demo application
- 독일
- 김봉두
- 독일 이민
- 독일이민
- 사무실
- 독일 IT
- 독일 구직
- 교사
- It
- CocoaPods
- 블루카드
- 호핑
- 호핑투어
- UbiVelox
- 학교
- mixnstand
- widget
- idle
- Programing
- 커피
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |