T - A simple testing framework using closures and errors

Related tags

Testing t
Overview

t

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 test if wanted.

Examples

t.suite

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)
}

t.expect

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

t.assert

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

t.log

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

XCTest

Assert suite is true

XCTAssert(
    t.suite {
        try t.assert(true)
    }
)

Assert expectation is true

XCTAssertNoThrow(
    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

XCTAssertThrowsError(
    try t.assert(false)
)
You might also like...
Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS
Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS

Mockingbird Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS, allowing a team to test and develop

Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine
Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine

Bluepill is a tool to run iOS tests in parallel using multiple simulators. Motivation LinkedIn created Bluepill to run its large iOS test suite in a r

Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5 and iOS 15.
Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5 and iOS 15.

StoreHelper Demo Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5, iOS 15. See also In-App Purchases with Xcode 12 and

I built this application with unit testing and test-driven development to understand TDD theory and practice
I built this application with unit testing and test-driven development to understand TDD theory and practice

TestDrivenDevelopment Description I built this application with unit testing and test-driven development to understand TDD theory and practice, to wri

A flexible mock server for automated and regression testing of iOS, Android and other apps.
A flexible mock server for automated and regression testing of iOS, Android and other apps.

Note: This document is intended as a quick introduction to Voodoo. As Voodoo has a large number of features, please refer to Voodoo's Github Wiki for

Snapshot testing tool for iOS and tvOS
Snapshot testing tool for iOS and tvOS

SnapshotTest is a simple view testing tool written completely in Swift to aid with development for Apple platforms. It's like unit testing for views.

UI Testing Cheat Sheet and Examples.

UI Testing Cheat Sheet This repository is complementary code for my post, UI Testing Cheat Sheet and Examples. The post goes into more detail with exa

A Mac and iOS Playgrounds Unit Testing library based on Nimble.
A Mac and iOS Playgrounds Unit Testing library based on Nimble.

Spry Spry is a Swift Playgrounds Unit Testing library based on Nimble. The best thing about Spry is that the API matches Nimble perfectly. Which means

Multivariate & A/B Testing for iOS and Mac

This library is no longer being maintained. You can continue to use SkyLab in your projects, but we recommend switching another solution whenever you

Releases(1.0.0)
  • 1.0.0(Nov 3, 2022)

    t

    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.

    Examples

    t.suite

    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)
    }
    

    t.expect

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

    t.assert

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

    t.log

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

    XCTest

    Assert suite is true

    XCTAssert(
        t.suite {
            try t.assert(true)
        }
    )
    

    Assert expectation is true

    XCTAssertNoThrow(
        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

    XCTAssertThrowsError(
        try t.assert(false)
    )
    

    What's Changed

    • Add Swift async support and unwrap and throwing functions by @0xLeif in https://github.com/0xOpenBytes/t/pull/2

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

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Feb 24, 2022)

    What's Changed

    Updated

    • tError renamed TestError
    • TestError is now public
    • Regenerated Documentation

    Added

    • Overridable Emojis to be used when logging
    • tested
    • async

    Full Changelog: https://github.com/0xOpenBytes/t/compare/0.1.0...0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Feb 3, 2022)

    t

    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 test if wanted.

    Examples

    t.suite

    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)
    }
    

    t.expect

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

    t.assert

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

    t.log

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

    XCTest

    Assert suite is true

    XCTAssert(
        t.suite {
            try t.assert(true)
        }
    )
    

    Assert expectation is true

    XCTAssertNoThrow(
        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

    XCTAssertThrowsError(
        try t.assert(false)
    )
    
    Source code(tar.gz)
    Source code(zip)
Owner
OpenBytes
OpenBytes
Assertions for XCTest which prevent fatal errors causing the process to die.

Hela Assertions for XCTest which prevent fatal errors causing the process to die. The following assertions are supported. These functions are built on

Brennan Stehling 3 Nov 7, 2022
Switchboard - easy and super light weight A/B testing for your mobile iPhone or android app. This mobile A/B testing framework allows you with minimal servers to run large amounts of mobile users.

Switchboard - easy A/B testing for your mobile app What it does Switchboard is a simple way to remote control your mobile application even after you'v

Keepsafe 287 Nov 19, 2022
SwiftCheck is a testing library that automatically generates random data for testing of program properties

SwiftCheck QuickCheck for Swift. For those already familiar with the Haskell library, check out the source. For everybody else, see the Tutorial Playg

TypeLift 1.4k Dec 21, 2022
Testing the UI without UI Testing, a Swift experiment.

UI tests without UI Testing experiment This repo is a small experiment to see if there's an "in-between" for testing iOS applications. More feature-le

Joe Masilotti 20 Sep 26, 2022
Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running in minutes. @buildasaur

Buildasaur Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running

Buildasaurs 774 Dec 11, 2022
The Swift (and Objective-C) testing framework.

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. // Swift import Quick import Nimbl

Quick 9.6k Dec 31, 2022
Remote configuration and A/B Testing framework for iOS

MSActiveConfig v1.0.1 Remote configuration and A/B Testing framework for iOS. Documentation available online. MSActiveConfig at a glance One of the bi

Elevate 78 Jan 13, 2021
Genything is a framework for random testing of a program properties.

Genything is a framework for random testing of a program properties. It provides way to random data based on simple and complex types.

Just Eat Takeaway.com 25 Jun 13, 2022
AB testing framework for iOS

ABKit Split Testing for Swift. ABKit is a library for implementing a simple Split Test that: Doesn't require an HTTP client written in Pure Swift Inst

Recruit Marketing Partners Co.,Ltd 113 Nov 11, 2022
Keep It Functional - An iOS Functional Testing Framework

IMPORTANT! Even though KIF is used to test your UI, you need to add it to your Unit Test target, not your UI Test target. The magic of KIF is that it

KIF Framework 6.2k Dec 29, 2022