hammerlab / test-utils   1.5.1

Apache License 2.0 GitHub

Unit-testing utilities

Scala versions: 2.12 2.11


Build Status codecov Maven Central

  • suite: test suites, custom matchers, and more for the JVM and JS
  • base: JVM-specific extensions to suite that adds filesystem-utilities (e.g. creating temporary files/directories)


libraryDependencies += "org.hammerlab.test" %%% "suite" % "1.1.0"


libraryDependencies += "org.hammerlab.test" %% "base" % "1.1.0"


  • Suite: wrapper for ScalaTest FunSuite with Matchers.
  • TmpFiles: create (and automatically garbage-collect) temporary files and directories.
  • matchers: various ScalaTest Matcher implementations:
    • files: file- and directory-equality Matchers:

      • FileMatcher: assert that two files' contents are equal, where the "expected" path is interpreted as being a path to a test-resource, and the "actual" path is absolute (e.g. a temporary file that was written via TmpFiles above):

        import org.hammerlab.test.matchers.files.FileMatcher.fileMatch
        actualPath should fileMatch(expectedPath)
      • [DirMatcher](https://github.com/hammerlab/test- utils/blob/master/src/main/scala/org/hammerlab/test/matchers/files/DirMatcher.scala): similar to the above, but verifying two directories' contents, highlighting missing, extra, and differing files.

        import org.hammerlab.test.matchers.files.DirMatcher.dirMatch
        actualPath should dirMatch(expectedPath)
    • seqs: collection-related Matchers:

      • SeqMatcher/SetMatcher: compare two Seqs, highlighting extra/missing elements.
      • PairSeqMatcher/MapMatcher: compare two collections of key-value pairs, highlighting missing/extra elements as well as keys whose values differ.
  • LazyAssert: an assert wrapper whose failure-message is evaluated lazily; useful in case it is expensive to compute (e.g. materializes/indexes data to provide context for debugging).
  • version.Util: test the Scala version, at runtime.