Private methods in traits end up as static methods in a synthetic
class generated by the Scala compiler, with a name formed by adding
"$class" to the trait name. So that's a bit more difficult to use
reflection to test. There are some options, which are described in the
ScalaDoc for PrivateMethodTester:
One limitation to be aware of is that you can't use
PrivateMethodTester to test a private method declared in a trait,
because the class the trait gets mixed into will not declare that
private method. Only the class generated to hold method
implementations for the trait will have that private method. If you
want to test a private method declared in a trait, and that method
does not use any state of that trait, you can move the private method
to a companion object for the trait and test it using
PrivateMethodTester that way. If the private trait method you want to
test uses the trait's state, your best options are to test it
indirectly via a non-private trait method that calls the private
method, or make the private method package access and test it directly
via regular static method invocations.
ScalaDoc is here:
http://www.scalatest.org/scaladoc/doc-1.0/org/scalatest/PrivateMethodTester.html
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
>
Thanks.
Bill
----
Bill Venners
Artima, Inc.
http://www.artima.com