美文网首页
iOS 单元测试和 UITests

iOS 单元测试和 UITests

作者: 我会回来的 | 来源:发表于2022-06-21 13:28 被阅读0次

单元测试: 

代码如下: 

例子如下: 
1  Person.h 

#import

NS_ASSUME_NONNULL_BEGIN

@interface Person : NSObject

@property (nonatomic, strong) NSString *name;

@property (nonatomic, assign) NSInteger age;

- (instancetype)initWithInfo:(NSDictionary*)info; 

@end

NS_ASSUME_NONNULL_END

2  Person.m  

#import "Person.h"

@implementation Person

- (instancetype)initWithInfo:(NSDictionary*)info {

    self= [superinit];

    if(self) {

        self.name= info[@"name"];

        self.age= [info[@"age"]integerValue];

    }

    return self;}

@end 

测试用例: 测试正确  绿色对勾 ✅    测试错误  红色打❌

 ------测试Log

#ifdef DEBUG

#define TestLog(FORMAT, ...) fprintf(stderr,"[TEST LOG] %s\n",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

#else

#define TestLog(...)

#endif

-----------------------------------------------------------------------------------------------------

PSDTest.m 

- (void)testInitPersion {

    NSDictionary *dic = @{@"name":@"test",@"test":@25}; 

    Person*p = [[Personalloc]initWithInfo:dic];

    NSAssert([p.nameisEqualToString:dic[@"name"]],@"姓名不一致");

    NSAssert(p.age== [dic[@"age"]integerValue],@"年龄不一致");

    TestLog(@"  BLE Test Case START");

}   

相关文章

  • iOS 单元测试和 UITests

    单元测试: 代码如下: 例子如下:1 Person.h #import NS_ASSUME_NONNULL_BEG...

  • iOS 单元测试 Tests 和 UITests

    一 :前言 此篇文章是我自己探索来的,查看了很多前人写的文章,也看了很多 demo,稍微对此有了一些了解,所以就在...

  • iOS-UnitTests单元测试

    本文简介 1.UnitTests 2.XCTest 单元测试 3.OCMock 单元测试 4.UITests UI...

  • iOS单元测试 && UITests

    一 单元测试 单元测试用的好,开发起来也会快很多。单元测试对于我目前来说,就是为了方便测试一些功能是否正常运行,还...

  • 前言

    iOS的自动化测试经过各种搜索,得知主要有3种 1.UITests 利用Xcode自带的UITests,就是新建一...

  • iOS UITests

    UI Tests是什么? UI Tests是一个自动测试UI与交互的Testing组件 UI Tests有什么用?...

  • 自动化备用

    一、两种技术的比较 XCode的自动化测试包括:UnitTests与UITests,即:单元测试与界面测试。Ear...

  • iOS界面自动化测试: UITests与EarlGrey

    一、两种技术的比较 XCode的自动化测试包括:UnitTests与UITests,即:单元测试与界面测试。Ear...

  • iOS开发——单元测试

    iOS开发——单元测试 iOS开发——单元测试

  • 单元测试

    内容 单元测试 参考文章: [iOS单元测试系列]单元测试框架选型 iOS单元测试:Specta + Expect...

网友评论

      本文标题:iOS 单元测试和 UITests

      本文链接:https://www.haomeiwen.com/subject/rigsvrtx.html