• Effekt Logo Effekt Library
    • test
      • Assertion
        • assert
      • assertTrue
      • assertTrue
      • assertFalse
      • assertFalse
      • assert
      • assert
      • assert
      • assert
      • assert
      • assert
      • assert
      • assert
      • assertEqual
      • assertEqual
      • assertEqual
      • assertEqual
      • Test
        • success
        • failure
      • test
      • suite
      • suite
      • mainSuite
    • test
    • Jump to source: libraries/common/test.effekt
      Example usage: examples/stdlib/test
      • Assertion
        • assert (condition: Bool, msg: String): Unit / {}
      • assertTrue (condition: Bool, msg: String)
      • assertTrue (condition: Bool)
      • assertFalse (condition: Bool, msg: String)
      • assertFalse (condition: Bool)
      • assert (obtained: Int, expected: Int, msg: String): Unit / {Assertion}
      • assert (obtained: Bool, expected: Bool, msg: String): Unit / {Assertion}
      • assert (obtained: Char, expected: Char, msg: String): Unit / {Assertion}
      • assert (obtained: String, expected: String, msg: String): Unit / {Assertion}
      • assert (obtained: Int, expected: Int): Unit / {Assertion, Formatted}
      • assert (obtained: Bool, expected: Bool): Unit / {Assertion, Formatted}
      • assert (obtained: Char, expected: Char): Unit / {Assertion, Formatted}
      • assert (obtained: String, expected: String): Unit / {Assertion, Formatted}
      • assertEqual [A] (obtained: A, expected: A, msg: String): Unit / {Assertion}
      • assertEqual [A] (obtained: A, expected: A): Unit / {Assertion, Formatted}
      • assertEqual [A] (obtained: A, expected: A, msg: String) { equals: (A, A) => Bool }: Unit / {Assertion}
      • assertEqual [A] (obtained: A, expected: A) { equals: (A, A) => Bool } { show: (A) => String }: Unit / {Assertion, Formatted}
      • Test
        • success (name: String, duration: Int): Unit / {}
        • failure (name: String, msg: String, duration: Int): Unit / {}
      • test (name: String) { body: => Unit / {Assertion} }
      • Runs the `body` as a test under the given `name`
        See `suite` for examples.
      • suite (name: String, printTimes: Bool) { body: => Unit / {Test, Formatted} }: Bool / {}
      • Run a test suite with a given `name`.
        - If `printTimes` is `true` (or missing), prints out time in milliseconds.
        - Formats automatically using ANSI escapes.
        - Returns `true` if all tests succeed, otherwise returns `false`. If you want to exit the program on failure, see `mainSuite`.
        
        Example:
        ```effekt
        suite("My Tests") {
          test("1 + 1 == 2") {
            assertEqual(1 + 1, 2)
          }
        }
        ```
      • suite (name: String) { body: => Unit / {Test, Formatted} }: Bool / {}
      • See `suite` above.
      • mainSuite (name: String) { body: => Unit / {Test, Formatted} }: Unit / {}
      • Use as `def main() = mainSuite("...") { ... }`
        Recommended for standalone test files ran by CI.
        
        Exits after running all tests:
        - if all tests succeed, exits the program with success (exit code 0)
        - otherwise exits the program with failure (exit code 1)