Testing and quality

Code that a team can change is code with a check. A test says what a method must do before anyone edits it, a formatter makes the diff about the change rather than the white space, a linter refuses the constructs the team agreed against, and a doc comment says what a public method is for. None of the four needs a large framework, and all four fit in a build.

The part opens with the two test frameworks of the Scala ecosystem, MUnit and ScalaTest, then property-based testing with ScalaCheck: a rule over a hundred generated inputs instead of one example. The second half is quality: scalafmt for the layout, Scalafix for the rules a project writes down, WartRemover for the ones the compiler enforces, and scaladoc for the page a library publishes. Every tool is run on the same small program, so the outputs are the real ones.

065 MUnit a suite, test, assertEquals, intercept, and the report scala-cli prints Open 066 ScalaTest AnyFunSuite, assert, the Matchers DSL, and the same suite under ScalaTest Open 067 ScalaCheck properties a property, forAll, a generator, and the shrinking of a failure Open 068 scalafmt the config, --check, the diff it prints, and the editor integration Open 069 Scalafix a rule, --check, the diff, and the rules the tool ships with Open 070 WartRemover the compiler plugin, Var and Null, and the real error line Open 071 scaladoc a doc comment, @param and @return, and the HTML scaladoc writes Open

Lessons