The Artima Developer Community
Sponsored Link

ScalaTest/ScalaUtils Forum
Visibility and ScalaTest

1 reply on 1 page. Most recent reply: May 29, 2014 10:02 AM by Bill Venners

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Eric Fowler

Posts: 2
Nickname: wildsalmon
Registered: May, 2014

Visibility and ScalaTest Posted: May 29, 2014 12:25 AM
Reply to this message Reply
This should be easy.

I have a class and companion object:

class TestMe {}
object TestMe
private def foo()= {}

Note that foo() is private.

I wish to test foo() with ScalaTest, but it is marked private.

How do I make it visible?

I thought I could wrap *both* files in a package declaration, then modify my declaration of foo():

package TestBait{
class TestMe {}
object TestMe
private[TestBait] def foo()= {}

Then in my ScalaTest suite, I would wrap my code in the same package declaration.

Dudn't work.

There has to be a simple way to do this. If it were C++ I would make the test class a friend of the C++ class being tested.

What is the "school solution", if there is one?



Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Visibility and ScalaTest Posted: May 29, 2014 10:02 AM
Reply to this message Reply
Hi Eric,

If you really think that method should be private then I'd suggest you leave it private and test it with the PrivateMethodTester:


Flat View: This topic has 1 reply on 1 page
Topic: Problem with XML testreport generation Previous Topic   Next Topic Topic: ScalaTest with Multiple Jvm

Sponsored Links


Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use