Swiftpack.co - 0xOpenBytes/t as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by 0xOpenBytes.
0xOpenBytes/t 1.0.1
๐Ÿงช Quickly test expectations
โญ๏ธ 6
๐Ÿ•“ 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/0xOpenBytes/t.git", from: "1.0.1")


Quickly test expectations

What is t?

t is a simple testing framework using closures and errors. You have the ability to create a suite that has multiple steps, expectations, and asserts. Expectations can be used to expect one or multiple assertions.

Where can t be used?

t can be used to test quickly inside a function to make sure something is working as expected. t can also be used in unit tests if wanted.



t.suite {
    // Add an expectation that asserting true is true and that 2 is equal to 2
    try t.expect {
        try t.assert(true)
        try t.assert(2, isEqualTo: 2)
    // Add an assertion that asserting false is not true
    try t.assert(notTrue: false)
    // Add an assertion that "Hello" is not equal to "World"
    try t.assert("Hello", isNotEqualTo: "World")
    // Log a message
    t.log("๐Ÿ“ฃ Test Log Message")
    // Log a t.error
    t.log(error: t.error(description: "Mock Error"))
    // Log any error
    struct SomeError: Error { }
    t.log(error: SomeError())
    // Add an assertion to check if a value is nil
    let someValue: String? = nil
    try t.assert(isNil: someValue)
    // Add an assertion to check if a value is not nil
    let someOtherValue: String? = "๐Ÿ’ "
    try t.assert(isNotNil: someOtherValue)


try t.expect {
    let someValue: String? = "Hello"
    try t.assert(isNil: someValue)


try t.assert("Hello", isEqualTo: "World")


t.log("๐Ÿ“ฃ Test Log Message")


Assert suite is true

    t.suite {
        try t.assert(true)

Assert expectation is true

    try t.expect("true is true and that 2 is equal to 2") {
        try t.assert(true)
        try t.assert(2, isEqualTo: 2)

Assert is false

    try t.assert(false)


Stars: 6
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 week ago

What's Changed

Full Changelog: https://github.com/0xOpenBytes/t/compare/1.0.0...1.0.1

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics