文章目录
Sbt Test
1 Write a test using ScalaTest
ScalaTest is recommened by the official team. In my blog, I use ScalaTest 3.0.3
Please refer to the official Scala Doc to know how to use ScalaTest to write your test cases.
2 Run all test cases
# run the command in your IDE below
sbt clean coverage test
# the above is the most recommended way to run
# if you just want to get the test results, use this command is faster
sbt test
3 Get coverage report
I highly recommend this coverage tool, please refer to sbt-coverage to install it.
# after finishing step 1 (with coverage), we can get coverage report running the command below
sbt coverageReport
# Coverage reports will be in your `target/scala-<scala-version>/scoverage-report` # directory. There are HTML and XML reports.
# The XML is useful if you need to
# programatically use the results, or if you're writing a tool.
4 Run specific test file
# you can run specific test file as follows:
sbt "testOnly yourPakageName.yourClassName"
# eg: sbt "testOnly org.apache.spark.dolphin.configuration.defaultConfigTest"
All concluded by Ruifeng Tan