Go to file
Ahmed Shendy 81f4833ba9
Provide SwiftDoc for Waitable feature (#4)
* Provide SwiftDoc for Waitable feature

* Clean up
2023-03-31 18:53:57 +02:00
.github/workflows init 2023-03-05 16:34:38 -07:00
Sources/Test Provide SwiftDoc for Waitable feature (#4) 2023-03-31 18:53:57 +02:00
Tests/TestTests Update value paramter of Waiter to object (#3) 2023-03-31 16:36:08 +02:00
.gitignore init 2023-03-05 16:34:38 -07:00
LICENSE Create LICENSE 2023-03-05 16:35:02 -07:00
Package.resolved Leif/update dependencies (#2) 2023-03-29 18:02:18 -06:00
Package.swift Leif/update dependencies (#2) 2023-03-29 18:02:18 -06:00
README.md Update README.md 2023-03-05 16:41:19 -07:00

README.md

Test

🧪 Expect and assert

What is Test?

Test is a simple testing function that allows you to create test suites with multiple steps, expectations, and assertions. You can specify a name for the test suite, an instance of the Tester class to be used for running the tests, and a closure that contains the test steps.

Where can Test be used?

Test can be used anywhere! Test can be used to test quickly inside a function to make sure something is working as expected. It is especially useful when you want to test a complex piece of code with multiple steps and assertions. Test can even be used for your unit tests!

Examples

Simple test with assertions

try await Test(named: "Test someMethod()") { tester in
    try tester.assert(SomeClass.someMethod())
    try await tester.assertNoThrows(try await SomeClass.someOtherMethod())
    try tester.assert(SomeClass.someBooleanValue, isEqualTo: false)
}

Test with expectations

try Test(named: "Test someMethod() with expectations") { tester in
    try Expect("First step should succeed") {
        try SomeClass.someMethod()
    }
    
    tester.logInfo("Just finished first step")

    try Expect("Second step should succeed") {
        try SomeClass.someOtherMethod()
    }
            
    tester.logWarning("Something unexpected happened during the second step")

    try Expect("Final assertion should be true") {
        try tester.assert(SomeClass.someBooleanValue)
    }
    
    tester.logSuccess("All steps and assertions passed!")
}