This is a study note of uTest: a simple, intuitive testing library for Scala. It features a uniform syntax for writing and running tests using a uniform assertion syntax.
uTest only supports the essential testing tasks:
- writing test suite and tests
- sharing initialization between various tests
- asserting results with expected
- selecting which tests to run
Write and Run Tests
TestSuite to define a suite and group tests in
test("name") method inside
Tests to write each test that can be nested.
Shared code are defined in a block. Global variables are defined outside
TestRunner.runAsync(tests) to run async tests and return a
Future[T], or use
TestRunner.run(tests) to run and wait.
uTest uses a macro-powered
assert method that takes one or more bollean expressions.
a ==> b as a shorthand for
assert(a == b).
intercept[ErrorType] to verify that a block raises an exception.
eventually(tests: Boolean*) at least once true in a certain period of time.
continually(tests: boolean*) alwasy true in a period.
TretryInterval customize the check.
assertMatch checks pattern matching.
compileError asserts that a fragment of code fails to compile.
The implicit value
test.framework.TestPath is passed to each test. It has a sequence of strings that matches the current test path.
retry(number) to retry tests. Use
TestSuite.Retries for suite retries.
teardown() to do pre-test and after-tests global tasks in
utestAfterEach for pre and after work for each test in
utestAfterAll for the suite.
TestRunner.run(tests) to run uTest standalone.