ChouTi is a repository of Swift packages that provides frameworks, utilities and extensions to enhance development on Apple platforms.
Add the following to your Package.swift
file:
dependencies: [
// add the package to your package dependencies
.package(url: "https://github.com/honghaoz/ChouTi", from: "0.0.8"),
],
targets: [
// add products to your target dependencies
.target(
name: "MyTarget",
dependencies: [
.product(name: "ChouTi", package: "ChouTi"),
]
),
.testTarget(
name: "MyTargetTests",
dependencies: [
.product(name: "ChouTiTest", package: "ChouTi"),
]
),
]
ChouTi is a Swift framework that provides common utilities and extensions to enhance development on Apple platforms.
import ChouTi
...
ChouTiTest is a Swift testing framework for writing tests with simple, expressive syntax.
import ChouTiTest
class SomeTests: XCTestCase {
func testExample() throws {
// boolean
expect(expression).to(beTrue())
expect(expression) == true
expect(expression).to(beFalse())
expect(expression) == false
expect(expression).toNot(beTrue())
expect(expression) != true
// collection
expect(expression).to(beEmpty())
expect(expression).toNot(beEmpty())
// equal
expect(expression).to(beEqual(to: 2))
expect(expression) == 2
expect(expression).toNot(beEqual(to: 2))
expect(expression) != 2
expect(expression).to(beApproximatelyEqual(to: 2, within: 1e-6))
expect(expression).toNot(beApproximatelyEqual(to: 2, within: 1e-6))
// identical
expect(expression).to(beIdentical(to: object))
expect(expression) === object
// nil
expect(expression).to(beNil())
expect(expression) == nil
expect(expression).toNot(beNil())
expect(expression) != nil
// unwrap
try expect(unwrap(expression)) == expectedValue
// error
expect(try expression()).to(throwError(SomeError.error))
expect(try expression()).toNot(throwError(SomeError.error))
// error type
expect(try expression()).to(throwErrorOfType(SomeError.self))
// any error
expect(try expression()).to(throwAnError())
// eventually
expect(expression).toEventually(beTrue())
expect(expression).toEventually(beEmpty())
expect(expression).toEventually(beEqual(to: 2))
expect(expression).toEventually(beIdentical(to: object))
expect(expression).toEventuallyNot(beTrue())
expect(expression).toEventuallyNot(beEmpty())
}
}