Objective c LCOV不';我不上一些课
我有一个Abstract UIViewController,它有测试方法Objective c LCOV不';我不上一些课,objective-c,tdd,Objective C,Tdd,我有一个Abstract UIViewController,它有测试方法 @interface ABViewController : UIViewController @property (nonatomic, strong) NSMutableArray *testResults; - (void)test; - (void)testFailedWithMessag:(NSString *)message; @end @implementation ABViewController - (v
@interface ABViewController : UIViewController
@property (nonatomic, strong) NSMutableArray *testResults;
- (void)test;
- (void)testFailedWithMessag:(NSString *)message;
@end
@implementation ABViewController
- (void)testFailedWithMessag:(NSString *)message
{
if(self.testResults == nil)
{
self.testResults = [NSMutableArray array];
}
[self.testResults addObject:message];
}
@end
这个类的基本思想是测试未在.h中列出的私有方法
测试例程在子类的“测试”方法中实现。如下图所示
RootViewController是ABViewController的一个子类
@interface RootViewController ()
{
UIButton *testButton;
}
@end
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
testButton = [[UIButton alloc] init];
}
- (void)test
{
if(testButton==nil)
[self testFailedWithMessag:@"testButton is nil"];
}
@end
测试如下
- (void)testRootViewController
{
// allocation class instance
RootViewController *testClassInstance = [[RootViewController alloc] init];
// when
[testClassInstance view];
// implement test
[testClassInstance test];
// verify result
XCTAssertTrue(([[testClassInstance testResults] count] == 0), @"%@", [[testClassInstance testResults] description]);
}
我创建了ABViewController的几个子类,并运行了单元测试。LCOV显示测试覆盖率,但仅显示ABViewController
@interface RootViewController ()
{
UIButton *testButton;
}
@end
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
testButton = [[UIButton alloc] init];
}
- (void)test
{
if(testButton==nil)
[self testFailedWithMessag:@"testButton is nil"];
}
@end
我想查看项目中的所有ViewController。有办法吗?
功能的数量与ViewController的功能不匹配。为什么?我也有同样的问题!!你找到解决办法了吗?是的。列表上的名称是DIRECTORY,也是hoper-link。只需单击该目录名称,您将在该目录中看到类