In ScalaTest is there any difference between `should`, `can`, `must`

should and must are the same semantically. But it’s not about better documentation, it’s basically just down to personal stylistic preference (I prefer must for example). can is a little different. You can’t (nomen omen) use it directly as a matcher, it’s only available in a test descriptor. Quote from FlatSpec: Note: you can use … Read more

Scalatest – how to test println

If you just want to redirect console output for a limited duration, use the withOut and withErr methods defined on Console: val stream = new java.io.ByteArrayOutputStream() Console.withOut(stream) { //all printlns in this block will be redirected println(“Fly me to the moon, let me play among the stars”) }

“Unknown artifact. Not resolved or indexed” error for scalatest

If you just added the dependency, it might not have been downloaded yet. Refresh/reimport the project to do so. If it has already been downloaded, press Alt+Enter in IntelliJ on the lines with the warning and select the “update project resolvers’ indexes” quickfix, then select the “local cache” index and click “update”. You can verify … Read more

What is the === (triple-equals) operator in Scala Koans?

This is the triple-equals operator from ScalaTest. Have a look at this page: Getting Started with FunSuite. It says: ScalaTest lets you use Scala’s assertion syntax, but defines a triple equals operator (===) to give you better error messages. The following code would give you an error indicating only that an assertion failed: assert(1 == … Read more

How can I get complete stacktraces for exceptions thrown in tests when using sbt and testng?

Using hints found in the documentation here: (quoted) You can configure the output shown when running with sbt in four ways: 1) turn off color, 2) show short stack traces, 3) full stack traces, and 4) show durations for everything. To do so you must pass a -o argument to ScalaTest, and after the -o, … Read more