This is a (nearly) minimal setting for doing a unit testing for
Scala. Below I list the commands as a pense-bete. Scala package myPackage
includes MyLib.scala
that defines a function to test, and MyTestSuite.scala
that does the test; Two ScalaTest jar files are put into the repo for your
convenience.
I have intentionally avoided sbt, a complex beast. The commands below use only
scalac and scala. Use them from the directory where myPackage
can be accessed without additional scoping.
scalac -cp scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar myPackage/MyLib.scala myPackage/MyTestSuite.scala
scala -cp scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar org.scalatest.run myPackage.MyTestSuite
Run starting. Expected test count is: 2 MyTestSuite: - square(-1)=1 - square(0)=0 Run completed in 115 milliseconds. Total number of tests run: 2 Suites: completed 1, aborted 0 Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0