title: How to write scalatest unit test for scala object?
body: <p>I am trying to write a unit test for <strong>scala object</strong> with using <strong>scalatest</strong> but.
  I imported the following dependencies for my <code>sbt</code>; </p>
  
  <p><code>libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5"
  libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"</code></p>
  
  <p>How to write the test case for this code?</p>
  
  <pre><code>object Word {
  
    def readFile(): Map[String, Int] = {
      val counter = scala.io.Source.fromFile("filepath")
        .getLines.flatMap(_.split("\\W+"))
        .foldLeft(Map.empty[String, Int]) {
          (count, word) =&gt;
            count + (word -&gt;
              (count.getOrElse(word, 0) + 1))
        }
      counter
    }
  }
  </code></pre>