Skip to content

Commit

Permalink
Add some more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdeviant committed Apr 20, 2024
1 parent 3069117 commit 4b0fbf6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/startest.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@ import startest/runner
import startest/test_case.{type Test, Test}
import startest/test_tree.{type TestTree, Suite}

/// Defines a new test suite with the given name.
///
/// A suite is a way of grouping related tests together.
///
/// `describe`s may also be nested in other `describe`s to form a hierarchy of tests.
pub fn describe(name: String, suite: List(TestTree)) -> TestTree {
Suite(name, suite)
}

/// Defines a test with the given name.
pub fn it(name: String, body: fn() -> Nil) -> TestTree {
Test(name, body, False)
|> test_tree.Test
}

/// Skips a test defined using `it`.
///
/// This can be used to skip running certain tests, but without deleting the code.
/// For instance, you might want to do this if a test is flaky and you want to stop
/// running it temporarily until it can be fixed.
pub fn xit(name: String, _body: fn() -> Nil) -> TestTree {
Test(name, fn() { Nil }, True)
|> test_tree.Test
}

/// Runs the given tests and reports results using the provided list of `Reporter`s.
pub fn run_tests(tests: List(TestTree), reporters: List(Reporter)) -> Nil {
runner.run_tests(tests, reporters)
}

0 comments on commit 4b0fbf6

Please sign in to comment.