Where is this @VisibleForTesting
annotation coming from? Is it the one provided by the Guava library?
Most likely, this is just an informative annotation, just used to document the fact that you gave a more relaxed visibility to a method/constructor simply to allow unit testing.
In your case you would have to actually change the visibility of the constructor:
package p
class DummyClass private[p] (config: DummyConfig) extends Runnable {
def refresh() = {
// Does tons of things
}
def updateProperty() = {
// My method
}
}
Here if you put your unit test in the package p
you can access the constructor since it is now package private. Add the annotation to indicate that no production code is allowed to call the constructor (but again, it will depend on the good behavior of the other developers working on the project, the compiler will not enforce anything based on the annotation).