Swift 的命令行测试运行器。
$ brew tap neonichu/formulae
$ brew install xctester
注意:这需要 Xcode 7.0
创建烦人的 Xcode 项目仅为了运行测试真的是令人讨厌。使用 xctester
,您不再需要这样做。
考虑以下测试用例
import XCTest
class MyTests : XCTestCase {
func testAdd() {
let result = add(3, 5)
XCTAssertEqual(result, 8, "")
}
func testAddFail() {
XCTAssertTrue(false, "lol")
}
func testThrows() {
NSException.raise("Exception", format:"#yolo", arguments: getVaList([]))
}
}
简单地运行 xctester
将执行测试并给出结果
MyTests
✅ -[MyTests testAdd]
❌ -[MyTests testAddFail]
XCTAssertTrue failed - lol
❌ -[MyTests testThrows]
failed: caught "Exception", "#yolo"
Executed 2 tests, with 1 failures (1 unexpected) in 0.001 seconds
xctester 依据 MIT 授权协议授权。更多信息请参阅 LICENSE。