| View previous topic :: View next topic |
| Author |
Message |
Kopilman
Joined: 25 May 2006 Posts: 162
|
I'm being prevented from unit testing the internals of my application because I like to make things package-private if they shouldn't be used outside the package. But then tests can't test them out
Is it bad to put testcase classes in the same package as the non test classes? |
| |
|
|
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| That's one reason I believe private/public should be part of the documentation, and not part of the language semantics |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
Or am i doing something else wrong
Lusis Backwood JR, documentation doesn't force anything
I'd prefer an option to say, "only this package and this package can use it" |
| |
|
|
Poolkop
Joined: 01 Jun 2006 Posts: 123
|
| I've seen the tests separated into a different source folder or project, but still in the same package as the classes they test ... |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| Another good approach is taken by lisp, where unexported symbols can still be used in other packages, but using a different syntax |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
Poolkop, interesting
I looked at junit source
And they just have a bunch of methods/classes called internal
I think that's stupid and i'd prefer to avoid it |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| Kopilman, why not just make the members public? |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
I don't know what the definition of a member is unless it's sexual
You talking about instance variables? |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| Member of a class |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| Or the classes? |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| Classes, methods, ivars, etc |
| |
|
|
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| Because i don't want people using them |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| Then tell people not to use them |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
Well i may end up having to
But i wish i didn't
I think Poolkop 's idea may be better |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
| Having the language enforce privacy is not really compatible with modern development practices |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
Maybe that's cause the development practices are wrong
If my package represents a module
I'd prefer a simple entry point into it
And it would be better if i could prevent people from shooting themselves in the foot
With a compilation error |
| |
|
|
Lusis Backwood JR
Joined: 26 May 2006 Posts: 87 Location: United States
|
I like systems where I can look at any object or call any piece of code interactively
But java doesn't support this style |
| |
|
|
Kopilman
Joined: 25 May 2006 Posts: 162
|
| I don't know if i've used a language that has |
| |
|
|
|