When using a FunSuite or a FreeSpec, a failing test is shown like this in Maven:
*** RUN ABORTED ***
java.lang.RuntimeException: Unable to load a Suite class that was discovered in the runpath: fi.oph.tor.schema.TestTest
at org.scalatest.tools.DiscoverySuite$.getSuiteInstance(DiscoverySuite.scala:84)
at org.scalatest.tools.DiscoverySuite$$anonfun$1.apply(DiscoverySuite.scala:38)
at org.scalatest.tools.DiscoverySuite$$anonfun$1.apply(DiscoverySuite.scala:37)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1195)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
When converting same spec to FlatSpec the output makes more sense:
Discovery completed in 481 milliseconds.
Run starting. Expected test count is: 1
TestTest:
blah
- should boom *** FAILED ***
BOOM (TestTest.scala:7)
Run completed in 564 milliseconds.
Total number of tests run: 1
Suites: completed 2, aborted 0
Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0
*** 1 TEST FAILED ***
Here's the FunSpec I was testing with:
class TestTest extends FunSpec {
describe("LOL") {
assert(false, "BOOM")
}
}
Update: my FunSpec was crap. It should be more like
class TestTest extends FunSpec {
describe("LOL") {
it("boom") {
assert(false, "BOOM")
}
}
}
Anyway, the same issue remains with FreeSpecs. Is there a way to write a FreeSpec that doesn't fail in the discovery phase?
Ok. My bad :)
I have to include the in parts in FreeSpecs too.
Kthnxbye!
For those Googlers reaching this post: I got the same kind of stacktrace when using FlatSpec, and this can also be caused by having two tests with the exact same description. Changing the description for one of them resolved the issue.
I got the same exception using AnyFunSuite. @turiphro was right!
I got the same exception using AnyFlatSpec ... Once again, thanks to @turiphro :)
Most helpful comment
For those Googlers reaching this post: I got the same kind of stacktrace when using FlatSpec, and this can also be caused by having two tests with the exact same description. Changing the description for one of them resolved the issue.