【读书笔记】iOS-OCUnit-单元测试
2018-01-03 09:58
453 查看
一,新建立一个hello工程---》在左侧会看到helloTests---->helloTests.m.如下图所示。
二,打开查看会看到如下代码。
三,里面函数的说明。
1. -(void)setUp: 每个test方法执行前调用,用于类的创建,一些变量的初始化等
2. -(void)tearDown:每个test方法执行后调用
3. -(void)testXXX:这个是真正运行的测试方法,命名就是不带参数,以test开始。
四,Product-->Test--》运行测试。输出结果如下图所示:
参考资料:《iOS测试指南》
二,打开查看会看到如下代码。
#import <UIKit/UIKit.h> #import <XCTest/XCTest.h> @interface helloTests : XCTestCase @end @implementation helloTests - (void)setUp { [super setUp]; // Put setup code here. This method is called before the invocation of each test method in the class. } - (void)tearDown { // Put teardown code here. This method is called after the invocation of each test method in the class. [super tearDown]; } - (void)testExample { // This is an example of a functional test case. XCTAssert(YES, @"Pass"); } - (void)testPerformanceExample { // This is an example of a performance test case. [self measureBlock:^{ // Put the code you want to measure the time of here. }]; } @end
三,里面函数的说明。
1. -(void)setUp: 每个test方法执行前调用,用于类的创建,一些变量的初始化等
2. -(void)tearDown:每个test方法执行后调用
3. -(void)testXXX:这个是真正运行的测试方法,命名就是不带参数,以test开始。
四,Product-->Test--》运行测试。输出结果如下图所示:
Test Suite 'All tests' started at 2016-01-23 05:08:13 +0000 Test Suite 'helloTests.xctest' started at 2016-01-23 05:08:13 +0000 Test Suite 'helloTests' started at 2016-01-23 05:08:13 +0000 Test Case '-[helloTests testExample]' started. Test Case '-[helloTests testExample]' passed (0.000 seconds). Test Case '-[helloTests testPerformanceExample]' started. /Users/chenlihua/Desktop/hello/helloTests/helloTests.m:35: Test Case '-[helloTests testPerformanceExample]' measured [Time, seconds] average: 0.000, relative standard deviation: 121.431%, values: [0.000002, 0.000001, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000], performanceMetricID:com.apple.XCTPerformanceMetric_WallClockTime, baselineName: "", baselineAverage: , maxPercentRegression: 10.000%, maxPercentRelativeStandardDeviation: 10.000%, maxRegression: 0.100, maxStandardDeviation: 0.100 Test Case '-[helloTests testPerformanceExample]' passed (0.288 seconds). Test Suite 'helloTests' passed at 2016-01-23 05:08:13 +0000. Executed 2 tests, with 0 failures (0 unexpected) in 0.288 (0.289) seconds Test Suite 'helloTests.xctest' passed at 2016-01-23 05:08:13 +0000. Executed 2 tests, with 0 failures (0 unexpected) in 0.288 (0.290) seconds Test Suite 'All tests' passed at 2016-01-23 05:08:13 +0000. Executed 2 tests, with 0 failures (0 unexpected) in 0.288 (0.291) seconds
参考资料:《iOS测试指南》
相关文章推荐
- 【读书笔记】iOS-OCUnit-单元测试
- iOS开发 简述使用OCUnit对程序进行单元测试(UnitTest)
- iOS开发中使用OCUnit进行单元测试
- XCode 内置了 OCUnit 单元测试框架,但目前最好用的测试框架应该是 GHUnit。通过 GHUnit + OCMock 组合,我们可以在 iOS 下进行较强大的单元测试功能。本文将演示如何在
- iOS单元测试——OCUnit, GHUnit
- iOS进行单元测试OCUnit+xctool
- IOS-使用XCODE自带的单元测试UnitTest
- iOS开发那些事--编写OCUnit测试方法-逻辑测试方法
- Xcode6下iOS单元测试——XCTest和GHUnit框架简介和比较
- 使用OCUnit写单元测试---逻辑测试
- iOS开发那些事--编写OCUnit测试方法-逻辑测试方法
- iOS开发那些事--编写OCUnit测试方法-应用测试方法
- 单元测试之OCUnit
- 利用GHUnit编写iOS单元测试
- iOS开发那些事--OCUnit测试框架
- iOS开发那些事--编写OCUnit测试方法-应用测试方法
- IOS unitTest 单元测试
- ios单元测试之GHUnit
- iOS开发那些事--编写OCUnit测试方法-应用测试方法
- iOS开发那些事--OCUnit测试框架