Pure tests
If your tests do not require any capability provided by effect-types, you can use a simplified interface FunSuite
,
which comes with a single test
method and does not allow effectful tests.
Tests in FunSuite
are executed sequentially and without the performance overhead of effect
management.
object CatsFunSuite extends weaver.FunSuite {
test("asserts") { expect(Some(5).contains(5)) }
test("fails") { expect(Some(25).contains(5)) }
test("throws") { throw new RuntimeException("oops") }
}
repl.MdocSessionMdocAppCatsFunSuite
+ asserts 1ms
- fails 1ms
- throws 0ms
*************FAILURES*************
repl.MdocSessionMdocAppCatsFunSuite
- fails 1ms
assertion failed (funsuite.md:11)
test("fails") { expect(Some(25).contains(5)) }
| |
Some(25) false
- throws 0ms
RuntimeException: oops
funsuite.md:13 repl.MdocSession$MdocApp$CatsFunSuite$$anonfun$3#apply
funsuite.md:13 repl.MdocSession$MdocApp$CatsFunSuite$$anonfun$3#apply
Try.scala:210 scala.util.Try$#apply
Test.scala:32 weaver.Test$#pure
suites.scala:136 weaver.FunSuiteF#$anonfun$test$1
suites.scala:148 weaver.FunSuiteF#$anonfun$pureSpec$4
List.scala:250 scala.collection.immutable.List#map
List.scala:79 scala.collection.immutable.List#map
suites.scala:148 weaver.FunSuiteF#pureSpec
suites.scala:151 weaver.FunSuiteF#spec
Runner.scala:29 weaver.Runner#$anonfun$run$4
Stream.scala:1989 fs2.Stream$#$anonfun$parEvalMap$3
cats.effect.internals.<...>
java.util.concurrent.<...>
Total 3, Failed 2, Passed 1, Ignored 0, Cancelled 0
A FunSuite
alias is provided in each of the frameworks supported by weaver:
object MonixFunSuite extends weaver.monixcompat.FunSuite {
test("asserts") { expect(Some(5).contains(5)) }
}
object MonixBIOFunSuite extends weaver.monixbiocompat.FunSuite {
test("asserts") { expect(Some(5).contains(5)) }
}
object ZioBIOFunSuite extends weaver.ziocompat.FunSuite {
test("asserts") { expect(Some(5).contains(5)) }
}