内联 0.3.2

内联 0.3.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年11月

Unknown维护。



内联 0.3.2

  • 作者:
  • Ryan Davies

Inline旨在让开发者更容易创建与Xcode集成的测试框架,允许他们以任何想要的方式测试。

它是如何工作的?

测试用例子类化INLSenTestCase而不是SenTestCase,并返回一个测试数组的列表

@interface Tests : INLSenTestCase
@end

@implementation Tests

- (NSArray *)tests
{
    return @[[[INLTest alloc] initWithName:@"test" block:^{} delegate:nil]];
}

@end

Inline不会自己运行测试,而是透明地将它们发送到SenTestingKit。测试名称在日志中显示,并在与Xcode集成之前去除空格和标点符号。

可以通过分配代理来对测试进行上下文化

- (NSArray *)tests
{
    id<INLRunnable> beforeHook = [[INLHook alloc] initWithBlock:^{ /* Runs before the test */ }];
    id<INLRunnable> afterHook = [[INLHook alloc] initWithBlock:^{ /* Runs after the test */ }];
    id<INLTestDelegate> beforeFilter = [[INLBeforeFilter alloc] initWithRunnable:beforeHook];
    id<INLTestDelegate> afterFilter = [[INLAfterFilter alloc] initWithRunnable:afterHook];
    id<INLTestDelegate> context = [[INLContext alloc] initWithDelegates:@[beforeFilter, afterFilter]];
    return @[[[INLTest alloc] initWithName:@"test" block:^{ /* Runs in the middle */ } delegate:context]];
}

上下文是一个委托组,每个委托都过滤在测试之前或之后运行。任何遵守INLTestDelegate的对象都可以在这里使用,这使其扩展变得简单。另外,由于上下文也符合INLTestDelegate,它们可以嵌套在其他上下文中。

我如何创建期望?

Inline支持使用类似STAssertTrue(...)的SenTestingKit断言,以及支持SenTestingKit的任何期望框架

  1. Posit - 使用类似于RSpec的should-based语法定义应发生的操作。
  2. Expecta - 指定期望发生的操作。

基于Inline构建的测试框架

有关如何使用Inline实现自己的框架的示例,请参阅Specify

安装

通过将pod 'Inline', '~> 0.3.0'添加到Podfile来使用CocoaPods安装Inline。

许可证

Copyright (c) 2013 Ryan Davies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.