美文网首页
XCTestCase API

XCTestCase API

作者: 纳兰沫 | 来源:发表于2020-05-09 13:19 被阅读0次

    +setUp

    Provides an opportunity to customize initial state before a test case begins.
    提供了在测试用例开始之前自定义初始状态的机会
    

    +tearDown

    Provides an opportunity to perform cleanup after a test case ends.
    在测试用例结束后提供执行清除的机会
    

    -addTeardownBlock

    Registers a block of teardown code to be run after the current test method ends.
    注册一个拆卸代码块,以在当前测试方法结束后运行
    

    处理测试用例失败

    continueAfterFailure

    The default is YES. Set this property to NO within a test method to end execution of that method as soon as a failure occurs. 
    Other test methods in the suite may still execute after a test fails.
    默认值为是 在测试方法中将次属性设置为NO,以在发生故障后立即终止该方法的执行,测试失败后,套件中的其他测试方法可能仍会执行
    

    衡量绩效

    - measureBlock:

    Measures the performance of a block of code.
    衡量代码块的性能
    

    - measureMetrics:automaticallyStartMeasuring:forBlock

    Measures the performance of a block of code, optionally deferring the starting point for measurement.
    测量代码块的性能,可以选择推迟测量的起点
    

    -startMeasuring

    Starts the measurement of performance metrics within a block of code.
    在代码块内开始测量性能指标。
    

    -stopMeasuring

    Ends the measurement of performance metrics within a block of code.
    在代码块中结束性能指标的度量。
    

    defaultPerformanceMetrics

    Identifies the performance metrics measured when [`measure<wbr style="margin-bottom: 0px;">Block:`](apple-reference-documentation://hcnJonuUfI) is invoked.
    标识在调用measureBlock:时测量的性能指标。
    

    XCTPerformanceMetric

    Performance metrics that can be measured by XCTest.
    可以由XCTest衡量的性能指标。
    

    性能测试

    **- expectationWithDescription: **

    Creates a new expectation with an associated description.
    创建具有相关描述的新期望
    

    - expectationForPredicate:evaluatedWithObject:handler:

    Creates an expectation that is fulfilled if the predicate returns YES when evaluated with the given object.
    如果谓词在使用给定对象进行评估时返回YES 则创建一个满足的期望
    

    - expectationForNotification:object:handler:

    Creates an expectation that is fulfilled when a specific [`NSNotification`](apple-reference-documentation://hcmB87CArc) is received for a given object.
    创建一个期望 该期望在给定对象接收到特定的Notifiacaiton时得到满足
    

    - keyValueObservingExpectationForObject:keyPath:expectedvalue:

    Creates an expectation that uses Key Value Observing to observe a value until it matches an expected value.
    创建一个期望 该期望使用"键值观察"观察一个值 直到他与期望值匹配为之
    

    - keyValueObservingExpectationForObject:keyPath:handler

    Creates an expectation that uses Key Value Observing to observe a value and respond to changes in that value by calling a provided handler.
    创建一个期望 该期望使用"键值观察"观察一个值并通过调研提供的处理程序来相应改值的更改
    

    异步期望得到满足

    - waitForExpectations:timeout:

    Waits on a group of expectations for up to the specified timeout.
    等待一组期望 直到达到指定的超时时间
    

    - waitForExpectations:timeout:enforceOrder:

    Waits on an array of expectations and specifies whether they must be fulfilled in the given order.
    等待一系列期望 并指定是否必须按给定顺序实现他们
    

    - waitForExpectationsWithTimeout:handler

    Waits until all expectations are fulfilled or the timeout is reached.
    等待直到所有期望都达到或超时
    

    XCWaitCOmpletionHandler

    A block to be called when a call to waitForExpectationsWithTimeout:handler
    has all of its expectations fulfilled, or times out.
    当调用waitForExpectationsWithTimeout:handler 满足其所有期望或者超时时,将调用该块
    

    **XCTestErrorCode
    **

    Error codes for errors that can occur while waiting for expectations to be fulfilled.
    等期望被实现时可能发生的错误的代码
    

    XCTestErrorDomain

    Error domain for errors that can occur while waiting for expectations to be fulfilled.
    错误域,用于等待期望被实现时可能发生的错误。
    

    监视UI中断

    - addUIInterruptionMonitorWithDescription:handler:

    Adds a handler to the current context.
    将处理程序添加到当前上下文。
    

    - removeUIInterruptionMonitor:

    Removes a handler using the token provided when it was added.
    使用添加时提供的令牌删除处理程序。
    

    相关文章

      网友评论

          本文标题:XCTestCase API

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