Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Test Driven Development Organization(How to organize Package Explorer)
Test Driven Development Organization [message #1125818] Fri, 04 October 2013 23:00 Go to next message
Mike McGuire is currently offline Mike McGuireFriend
Messages: 6
Registered: October 2013
Junior Member
I'm attempting to code using Test-Driven Development, but I'm not sure I understand how things should be set up in Package Explorer. As you can see in the attached screenshot, I'm trying to write a game called Dot-Com. That's what I named the package. Then, with that highlighted, I created two new classes, one of which is my testing class.

I may be teaching an Intro to Java Programming class in the spring and want to use best practices. Am I doing this right? Thanks...

index.php/fa/16392/0/
Re: Test Driven Development Organization [message #1126149 is a reply to message #1125818] Sat, 05 October 2013 07:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Mike,

It's not obvious what the errors are; is that your concern? In general,
"real programers" don't define classes in the default package, but
rather use some type of proper package name so that the classes defined
can be used potentially anywhere. I imagine it's also commonly the case
to keep the tests separate (in a separate project) from the thing being
tested. Also keep in mind that this forum is intended to ask questions
about Eclipse and not so much plain old general Java questions, for
which something like StackOverflow is more appropriate...


On 05/10/2013 2:17 AM, Mike McGuire wrote:
> I'm attempting to code using Test-Driven Development, but I'm not sure I understand how things should be set up in Package Explorer. As you can see in the attached screenshot, I'm trying to write a game called Dot-Com. That's what I named the package. Then, with that highlighted, I created two new classes, one of which is my testing class.
>
> I may be teaching an Intro to Java Programming class in the spring and want to use best practices. Am I doing this right? Thanks...
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Test Driven Development Organization [message #1126879 is a reply to message #1125818] Sun, 06 October 2013 02:59 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 10/04/2013 06:17 PM, Mike McGuire wrote:
> I'm attempting to code using Test-Driven Development, but I'm not sure I understand how things should be set up in Package Explorer. As you can see in the attached screenshot, I'm trying to write a game called Dot-Com. That's what I named the package. Then, with that highlighted, I created two new classes, one of which is my testing class.
>
> I may be teaching an Intro to Java Programming class in the spring and want to use best practices. Am I doing this right? Thanks...

Ed gave you some good information. A really good resource for Java-only
questions is javaranch.com. It's very much kinder and gentler.
stackoverflow.com is usually much faster, but not always kinder and gentler.

Anticipating, however, where you're going with this, your
SimpleDotComTestDrive.java code should go on a different path (just as
you suspected). In Eclipse, create that path thus:

1. Right-click your project and choose New -> Source Folder. Name the
new folder "test".

2. Right-click both src and test and create proper new packages in them
(as Ed suggested). (default package) will disappear. Use the same
package name in both places. If you don't personally have a domain name,
then make something up such as mcguire.mike.games. It doesn't matter
what it is as long as you keep it "in-house" and the package name can be
changed any time you want; Eclipse makes this very easy!

3. Right-click SimpleDotCom.java and choose Refactor -> Move and move it
into the new package under src. Do the same thing for your test code
except move it under the new package under the new test subdirectory.
The Eclipse Refactor -> Move command automatically updates the package
name inside your source code.

So, in the end, you should see something like:

SimpleDotComGame
+- src
| +- mcguire.mike.games
| +- SimpleDotCom.java
|
+- test
+- mcguire.mike.games
+- SimpleDotComTestDrive.java

Hope this helps. I'll tell you up front that Eclipse defaults to a
simpler project subdirectory format than traditional Java. So expect to
see much greater depth (something like src/main/java/com/domain/...) in
some answers or examples when you look around.

Hope this helps.

Russ
P.S. Eclipse is better!
Re: Test Driven Development Organization [message #1127222 is a reply to message #1125818] Sun, 06 October 2013 12:05 Go to previous message
Mike McGuire is currently offline Mike McGuireFriend
Messages: 6
Registered: October 2013
Junior Member
Thank you both, Gentlemen, for helping me out. I'll follow all your suggestions...
Previous Topic:eclipse ide for development of not open source software
Next Topic:Problems starting Eclipse after Java 7 install
Goto Forum:
  


Current Time: Tue Apr 23 15:26:01 GMT 2024

Powered by FUDForum. Page generated in 0.08224 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top