zhoulaifu / helloworld_ScalaTest

Minimal setting for unittesting Scala, without using sbt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is this

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.

How to compile

scalac -cp scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar myPackage/MyLib.scala myPackage/MyTestSuite.scala

How to run the tests

scala -cp scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar org.scalatest.run myPackage.MyTestSuite

Expected results

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

About

Minimal setting for unittesting Scala, without using sbt


Languages

Language:Scala 100.0%