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:31 weaver.Test$#pure
suites.scala:187 weaver.FunSuiteF#$anonfun$test$1
suites.scala:197 weaver.FunSuiteF#$anonfun$pureSpec$1
List.scala:250 scala.collection.immutable.List#map
List.scala:79 scala.collection.immutable.List#map
suites.scala:197 weaver.FunSuiteF#pureSpec
suites.scala:201 weaver.FunSuiteF#spec
Runner.scala:33 weaver.Runner#$anonfun$run$5
Stream.scala:2187 fs2.Stream#$anonfun$parEvalMapActionImpl$6
ApplicativeError.scala:269 cats.ApplicativeError#catchNonFatal
ApplicativeError.scala:268 cats.ApplicativeError#catchNonFatal$
IO.scala:1606 cats.effect.IO$$anon$4#catchNonFatal
Stream.scala:2187 fs2.Stream#$anonfun$parEvalMapActionImpl$5
IOFiber.scala:1177 cats.effect.IOFiber#succeeded
IOFiber.scala:271 cats.effect.IOFiber#runLoop
IOFiber.scala:1324 cats.effect.IOFiber#execR
IOFiber.scala:118 cats.effect.IOFiber#run
WorkerThread.scala:585 cats.effect.unsafe.WorkerThread#run
Total 3, Failed 2, Passed 1, Ignored 0, Cancelled 0