title: How can a private class method be tested in Scala?
body: <p>I have a companion object with a private method, like so:</p>
  
  <pre><code>package com.example.people
  
  class Person(val age: Int)
  
  object Person {
    private def transform(p: Person): Person = new Person(p.age + 1)
  }
  </code></pre>
  
  <p>I would like to test this method, with something like:</p>
  
  <pre><code>class PersonSpec extends FlatSpec {
  
    "A Person" should "transform correctly" in {
      val p1 = new Person(1)
      val p2 = Person.transform(p1) // doesn't compile, because transform is private!
      assert( p2 === new Person(2) )
    }
  
  }
  </code></pre>
  
  <p>Any help on having test code access private methods?</p>
  
  <p>Actually, as it is written, I might be able to create a subclass of <code>Person</code>, but what if <code>Person</code> is declared as <code>final</code> or <code>sealed</code>?</p>
  
  <p>Thanks!</p>