2013-06-12 3 views
0

UIViews에서 drawRect 함수를 재정 의하여 응용 프로그램에 다양한 모양을 그리는 응용 프로그램을 작성하고 있습니다.UIView에서 drawRect를 재정의하면 IOS 단위 테스트가 예외를 throw합니다.

나는 보통 inbuilt SenTestingKit을 사용하여 모든 응용 프로그램을 단위 테스트합니다. contextRefCG 드로잉을 포함 시키 자마자 테스트를 실행할 때마다 일련의 예외가 표시되고 테스트가 실행되지 않습니다. drawRect 함수를 주석 처리하면 테스트가 컴파일되어 다시 실행됩니다. 내가 볼

오류 메시지는 다음과 같습니다 여기

Undefined symbols for architecture i386: 
    "_CGContextAddArc", referenced from: 
     -[HeartShapeView drawRect:] in HeartShapeView.o 
    "_CGContextAddLineToPoint", referenced from: 
     -[SquareShapeView drawRect:] in SquareShapeView.o 
     -[HeartShapeView drawRect:] in HeartShapeView.o 
    "_CGContextBeginPath", referenced from: 
     -[SquareShapeView drawRect:] in SquareShapeView.o 
     -[HeartShapeView drawRect:] in HeartShapeView.o 
    "_CGContextClosePath", referenced from: 
     -[SquareShapeView drawRect:] in SquareShapeView.o 
     -[HeartShapeView drawRect:] in HeartShapeView.o 

내의 drawRect 내 내 SquareShapeView 중 하나에 코드입니다

- (void)drawRect:(CGRect)rect 
{ 
    CGFloat small = rect.size.width; 
    small = (rect.size.height <= rect.size.width) ? rect.size.height : small; 

    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); 

    CGContextBeginPath(context); 

    CGContextMoveToPoint(context, 0.0f, 0.0f); 
    CGContextAddLineToPoint(context, 0.0f, small); 
    CGContextAddLineToPoint(context, small, small); 
    CGContextAddLineToPoint(context, small, 0.0f); 

    CGContextClosePath(context); 
    CGContextSetLineWidth(context, 1.0f); 

    CGContextStrokePath(context); 
} 

답변

1

당신은 테스트 대상으로 CoreGraphics 프레임 워크를 포함하는 것을 잊지

+0

브릴리언트. 고마워. 인생은 갑자기 해결되고 TDD로 돌아갈 수 있습니다. – Marryat