TestResult
A test result.
On JVM and Native, this resolves to Unit, representing the fact that tests are run in a blocking manner on these platforms: a call to a function returning a TestResult will simply execute the test inside it.
On JS, this is a
Promise
, which reflects the fact that the test-running function does not wait for a test to finish. The JS test frameworks typically support returningPromise
from a test and will correctly handle it.
Because of the behavior on JS, extra care must be taken when writing multiplatform tests to avoid losing test errors:
Don't do anything after running the functions returning a TestResult. On JS, this code will execute before the test finishes.
As a corollary, don't run functions returning a TestResult more than once per test. The only valid thing to do with a TestResult is to immediately
return
it from a test.Don't nest functions returning a TestResult.